Took me long enough, but I figured it out. Let me know if there is a better way...
PHP Code:
#include < amxmodx >
#include < hamsandwich >
#include < fun >
#include < fakemeta >
const m_pPlayer = 41;
public plugin_init( )
{
new WeaponName[ 32 ];
// no knifes, deagle, nades or c4
new NoPrimaryAttack = ( ( 1 << CSW_GLOCK18 ) | ( 1 << CSW_KNIFE ) | ( 1 << CSW_DEAGLE ) | ( 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 );
if( is_user_bot( id ) && pev(id, pev_flags) & ~IN_JUMP & FL_ONGROUND)
set_pev( id , pev_velocity , 0 ) // set low speed
}
public Ham_Weapon_PrimaryAttack_Post( Weapon )
{
new id = get_pdata_cbase( Weapon, m_pPlayer, 4 );
if( is_user_bot( id ) && ~pev(id, pev_flags) & IN_JUMP & FL_ONGROUND)
set_pev( id , pev_velocity , 250 ) // reset speed
}