This will only fire on a true weapon switch, not when a new weapon is picked up or purchased.
Edit: Just realized WATCH_D0GS UNITED posted essentially the same thing. I saw a lot of orange in his post & assumed it was psuedo-code and it was TLDR so I skipped over it.
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <fakemeta>
#include <hamsandwich>
new const Version[] = "0.1";
const IGNORE_ITEMS = ( ( 1 << CSW_HEGRENADE ) | ( 1 << CSW_SMOKEGRENADE ) | ( 1 << CSW_FLASHBANG ) | ( 1 << CSW_C4 ) );
public plugin_init()
{
register_plugin( "Admin Weapon Switch" , Version , "bugsy" );
for ( new iWeaponID = CSW_P228 , szWeaponName[ 23 ]; iWeaponID <= CSW_P90 ; iWeaponID++ )
{
if ( !( IGNORE_ITEMS & ( 1 << iWeaponID ) ) && get_weaponname( iWeaponID , szWeaponName , charsmax( szWeaponName ) ) )
RegisterHam( Ham_Item_Deploy , szWeaponName , "DeployWeapon" );
}
}
public DeployWeapon( iEntity )
{
new id = pev( iEntity , pev_owner );
if ( ( 1 <= id <= MAX_PLAYERS ) && is_user_admin( id ) )
{
new szWeaponName[ 23 ];
new iWeaponID = cs_get_weapon_id( iEntity );
get_weaponname( iWeaponID , szWeaponName , charsmax( szWeaponName ) );
client_print( 0 , print_chat , "Admin switched to %s" , szWeaponName[ 7 ] );
}
}
__________________