This plugin has the function that when we remove the muffler from the USP or M4A1, it shows the model (p_USP and p_m4a1) of the weapons without the muffler, it works fine but when you have the p_m4a1 o p_usp with without muffler and buy a gun or grenade it shows the muffler of the weapon
PHP Code:
/* Plugin generated by AMXX-Studio */
#include <amxmodx>
#include <cstrike>
#include <engine>
#include <fakemeta>
#include <hamsandwich>
#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "author"
const m_pActiveItem = 373;
new const P_M4[][] = {"models/p_m4a1_unsil.mdl", "models/p_m4a1.mdl"};
new const P_USP[][] = {"models/p_usp_unsil.mdl", "models/p_usp.mdl"};
public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR)
register_event("CurWeapon", "Event_CurWeapon", "be","1=1");
register_forward(FM_CmdStart, "Fw_CmdStart");
}
public plugin_precache()
{
precache_model(P_M4[0]);
precache_model(P_USP[0]);
}
public Fw_CmdStart(id, uc_handle, seed)
{
if(!is_user_alive(id))
return
new wpn_id = get_user_weapon(id);
static NewButton;
NewButton = get_uc(uc_handle, UC_Buttons);
if(NewButton & IN_ATTACK2)
if(NewButton & IN_ATTACK2)
if(wpn_id == CSW_M4A1 || wpn_id == CSW_USP)
silencers(id, wpn_id);
}
public Event_CurWeapon(id)
{
if(!is_user_connected(id) || !is_user_alive(id))
return
new wpn_id = get_user_weapon(id);
if(wpn_id == CSW_M4A1 || wpn_id == CSW_USP)
silencers(id, wpn_id);
}
silencers(id, wpn_id)
{
new wpn = get_pdata_cbase(id, m_pActiveItem);
static model[32];
pev(id, pev_weaponmodel2, model, 31);
switch(wpn_id)
{
case CSW_M4A1:
{
if(!equal(model, P_M4[cs_get_weapon_silen(wpn)]))
set_pev(id, pev_weaponmodel2, P_M4[cs_get_weapon_silen(wpn)]);
else
return
}
case CSW_USP:
{
if(!equal(model, P_USP[cs_get_weapon_silen(wpn)]))
set_pev(id, pev_weaponmodel2, P_USP[cs_get_weapon_silen(wpn)]);
else
return
}
}
}