Code:
#include < amxmodx >
#include < hamsandwich >
#include < fun >
const m_pPlayer = 41;
public plugin_init( )
{
new WeaponName[ 32 ];
// no knifes, nades or c4
new NoPrimaryAttack = ( ( 1 << CSW_KNIFE ) | ( 1 << CSW_HEGRENADE ) | ( 1 << CSW_FLASHBANG ) | ( 1 << CSW_SMOKEGRENADE ) | ( 1 << CSW_C4 ) );
for( new CSWConstant = CSW_P228; CSWConstant <= CSW_P90; CSWConstant++ )
{
if( ~NoPrimaryAttack & ( 1 << CSWConstant ) // check for invalid CSW_* constants
&& get_weaponname( CSWConstant, WeaponName, charsmax( WeaponName ) ) ) // get weaponname
{
RegisterHam( Ham_Weapon_PrimaryAttack, WeaponName, "Ham_Weapon_PrimaryAttack_Pre", 0 ); // hook pre
RegisterHam( Ham_Weapon_PrimaryAttack, WeaponName, "Ham_Weapon_PrimaryAttack_Post", 1 ); // hook post
}
}
}
public Ham_Weapon_PrimaryAttack_Pre( Weapon )
{
new id = get_pdata_cbase( Weapon, m_pPlayer, 4 );
set_user_maxspeed( id, 0.1 ); // set low speed
}
public Ham_Weapon_PrimaryAttack_Post( Weapon )
{
new id = get_pdata_cbase( Weapon, m_pPlayer, 4 );
set_user_maxspeed( id ); // reset speed
}
__________________