PHP Code:
public plugin_init()
{
for(new i=CSW_P228, szClassname[32]; i <= CSW_P90; i++)
{
if((get_weaponname(i, szClassname, charsmax(szClassname)) > 7) && ((1<<i) & (CSW_ALL_PISTOLS|CSW_ALL_GRENADES|(1<<CSW_KNIFE))))
{
RegisterHam(Ham_Item_Deploy, szClassname, "fw_weapon_deploy", true);
}
else if(szClassname[0] != 0)
{
RegisterHam(Ham_Item_Deploy, szClassname, "fw_weapon_remove", true);
}
}
}
public fw_weapon_deploy(ent)
{
new id = pev(ent, pev_owner), ent;
if(id > 0 && (ent=ENT_PLAYER[id]) > 0)
{
engfunc(EngFunc_SetModel, ent, "");
new aWeapons[32], szWeaponName[32], wpnum = 0, currwpn;
get_user_weapons(id, aWeapons, wpnum);
const m_iId = 43
currwpn = (1<<get_pdata_int(ent, m_iId, 4)); // get used weapon...
for(new i = 0, szString[64], szClassname[32]; i < wpnum; i++)
{
client_print(id, print_chat, "currwpn: %d WpnID: %d", get_pdata_int(ent, m_iId, 4), aWeapons[i]);
if( ( (1<<aWeapons[i]) & ( (0xFFFFFF & ~0x000001) & ~(currwpn|CSW_ALL_PISTOLS|CSW_ALL_GRENADES|(1<<CSW_KNIFE)) ) ) > 0)
{
if(get_weaponname(aWeapons[i], szClassname, charsmax(szClassname)) > 7) {
formatex(szString, charsmax(szString), "models/w_%s.mdl", szClassname[7]);
engfunc(EngFunc_SetModel, ent, szString);
break;
}
}
}
}
}
public fw_weapon_remove(ent)
{
new id = pev(ent, pev_owner), ent;
if(id > 0 && (ent=ENT_PLAYER[id]) > 0)
{
engfunc(EngFunc_SetModel, ent, "");
}
}
Outputs :-
Code:
currwpn: 0 WpnID: 4
currwpn: 0 WpnID: 9
currwpn: 0 WpnID: 25
currwpn: 0 WpnID: 26
currwpn: 0 WpnID: 28
currwpn: 0 WpnID: 29
meta list
Code:
Currently loaded plugins:
description stat pend file vers src load unlod
[ 1] AMX Mod X RUN - amxmodx_mm.dll v1.9.0.5 ini Start ANY
[ 2] POD-Bot mm RUN - podbot_mm.dll vV3B22 ini Chlvl ANY
[ 3] FakeMeta RUN - fakemeta_amxx.dl v1.9.0.5 pl1 ANY ANY
[ 4] Ham Sandwich RUN - hamsandwich_amxx v1.9.0.5 pl1 ANY ANY
[ 5] CSX RUN - csx_amxx.dll v1.9.0.5 pl1 ANY ANY
[ 6] CStrike RUN - cstrike_amxx.dll v1.9.0.5 pl1 ANY ANY
[ 7] Fun RUN - fun_amxx.dll v1.9.0.5 pl1 ANY ANY
7 plugins, 7 running
__________________