On windows this works rights, pressing the right click I can execute the related function, but on linux it just works 1 time and after that I ALSO can't throw a nade, but on windows it works like a charm
PHP Code:
// CBasePlayerItem
const XO_CBASEPLAYERITEM = 4
const m_pPlayer = 41
// CBasePlayer
const XO_CBASEPLAYER = 5
const m_pClientActiveItem = 374
// CBaseMonster
const XO_CBASEMONSTER = 5
const m_flNextAttack = 83
// CBaseEntity
const XO_CBASEENTITY = 3
const m_flStartThrow = 30
// CBasePlayerWeapon
const XO_CBASEPLAYERWEAPON = 4
const m_flNextSecondaryAttack = 47
// plugin_init:
RegisterHam(Ham_Weapon_SecondaryAttack, "weapon_hegrenade", "OnHESecondaryAttack")
public OnHESecondaryAttack(hegrenade)
{
if(get_pdata_float(hegrenade, m_flStartThrow, XO_CBASEENTITY) > 0.0) // is this right? trying to check if grenade is not ready to throw
return HAM_IGNORED
new id = get_pdata_cbase(hegrenade, m_pPlayer, XO_CBASEPLAYERITEM)
if(!(1 <= id <= g_maxplayers))
return HAM_IGNORED
ExecuteHamB(Ham_Item_Holster, hegrenade, 0) // trying to do a weapon switch
set_pdata_cbase(id, m_pClientActiveItem, -1, XO_CBASEPLAYERWEAPON)
ExecuteHamB(Ham_Item_Deploy, hegrenade)
set_pdata_float(id, m_flNextAttack, 0.3, XO_CBASEMONSTER) // a delay of 0.3
set_pdata_float(hegrenade, m_flNextSecondaryAttack, 0.3, XO_CBASEPLAYERWEAPON)
client_print(id, print_center, "Pressed the button at %.2f", get_gametime())
return HAM_SUPERCEDE; // prevent supposed shield functions
}
EDIT: I've noticed that i set the wrong linux offset for ClientActiveItem, i was reseting ActiveItem and that was causing that i wasn't able to throw and those things. Thanks anyway