Hello people, I have a doubt as to how to change a model of a gun. Of course, Ham_Item_Deploy is the best option from what I've seen in several posts researching. But I'm in doubt about a plugin because it uses CurrentWeapon and Ham_item_deploy.
First:
PHP Code:
register_event("CurWeapon","CurrentWeapon","be","1=1")
In this event he:
PHP Code:
public CurrentWeapon(id)
{
replace_weapon_models(id, read_data(2))
if(read_data(2) != CSW_AWP || !g_has_sniper[id])
return
static Float:iSpeed
if(g_has_sniper[id])
iSpeed = get_pcvar_float(cvar_spd_sniper)
static weapon[32],Ent
get_weaponname(read_data(2),weapon,31)
Ent = find_ent_by_owner(-1,weapon,id)
if(Ent)
{
static Float:Delay
Delay = get_pdata_float( Ent, 46, 4) * iSpeed
if (Delay > 0.0)
{
set_pdata_float(Ent, 46, Delay, 4)
}
}
}
But he also uses Ham_Item_Deploy:
PHP Code:
for (new i = 1; i < sizeof WEAPONENTNAMES; i++)
if (WEAPONENTNAMES[i][0]) RegisterHam(Ham_Item_Deploy, WEAPONENTNAMES[i], "fw_Item_Deploy_Post", 1)
public fw_Item_Deploy_Post(weapon_ent)
{
static owner
owner = fm_cs_get_weapon_ent_owner(weapon_ent)
static weaponid
weaponid = cs_get_weapon_id(weapon_ent)
replace_weapon_models(owner, weaponid)
}
replace_weapon_models(id, weaponid)
{
switch (weaponid)
{
case CSW_AWP:
{
if (zp_get_user_zombie(id) || zp_get_user_survivor(id))
return
if(g_has_sniper[id])
{
set_pev(id, pev_viewmodel2, sniper_V_MODEL)
set_pev(id, pev_weaponmodel2, sniper_P_MODEL)
if(oldweap[id] != CSW_AWP)
{
UTIL_PlayWeaponAnimation(id, sniper_DRAW)
set_pdata_float(id, m_flNextAttack, 1.0, PLAYER_LINUX_XTRA_OFF)
message_begin(MSG_ONE, gmsgWeaponList, {0,0,0}, id)
write_string("weapon_sniperultra")
write_byte(4)
write_byte(90)
write_byte(-1)
write_byte(-1)
write_byte(0)
write_byte(16)
write_byte(CSW_AWP)
message_end()
}
}
}
}
oldweap[id] = weaponid
}
I noticed that if I remove the curweapon event, in the WeaponPickup event the sniper model defaults. Shouldn't ham_item_deploy switch? And also, currentweapon doesn't change the model every time the weapon is updated, so what is ham_item_deploy going to do?
And worse, will there be 2 functions working to change the model?