hamsandwich provides weapons forward so there are more efficient methods to block weapon firing.
I use this one :
PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
// weapons offsets
#define XO_WEAPONS 4
#define m_pPlayer 41
#define m_iId 43
#define m_flNextPrimaryAttack 46
#define m_flNextSecondaryAttack 47
// players offsets
#define XO_PLAYER 5
#define m_flNextAttack 83
public plugin_init()
{
new szWeaponName[20]
for(new i=CSW_P228; i<=CSW_P90; i++)
{
if( get_weaponname(i, szWeaponName, charsmax(szWeaponName)) )
{
RegisterHam(Ham_Item_Deploy, szWeaponName, "Weapons_Deploy", true)
}
}
}
public Weapons_Deploy(iWeapon)
{
// want to filter by player id ?
new id = get_pdata_cbase(iWeapon, m_pPlayer, XO_WEAPONS)
// want to filter by weapon type ?
// would be better not to register the corresponding weapon classname
// but you may mix player+weapontype filters...
new iId = get_pdata_int(iWeapon, m_iId, XO_WEAPONS) // you can use cs_get_weapon_id as well
// 99999.0 = 27hours, should be enough.
// want to block attack1 ?
set_pdata_float(iWeapon, m_flNextPrimaryAttack, 99999.0, XO_WEAPONS)
// want to block attack2 ?
set_pdata_float(iWeapon, m_flNextSecondaryAttack, 99999.0, XO_WEAPONS)
// also want to block +use ? (may block other things as impulse(impulse are put in a queue))
set_pdata_float(id, m_flNextAttack, 99999.0, XO_PLAYER)
}
__________________