#include <amxmodx>
#include <hamsandwich>
#include <fakemeta>
new g_MsgId_WeaponList;
public plugin_precache()
{
precache_generic( "sprites/weapon_HealthNade.txt" );
precache_generic( "sprites/640hud19.spr" );
precache_generic( "sprites/640hud20.spr" );
}
new const WEAPON_TO_CHANGE[] = "weapon_knife";
new const WEAPON_NEW[] = "weapon_HealthNade";
static const SLOT = 5;
public plugin_init()
{
RegisterHam( Ham_Item_AddToPlayer, WEAPON_TO_CHANGE, "OnAddToPlayerKnife", .Post = true );
RegisterHam( Ham_Item_ItemSlot, WEAPON_TO_CHANGE, "OnItemSlotKnife" );
register_clcmd( "weapon_ArkFlare", "ClientCommand_SelectFlare" );
g_MsgId_WeaponList = get_user_msgid( "WeaponList" );
}
public ClientCommand_SelectFlare( const client )
{
engclient_cmd( client, WEAPON_TO_CHANGE );
}
public OnAddToPlayerKnife( const item, const player )
{
if( pev_valid( item ) && is_user_alive( player ) ) // just for safety.
{
message_begin( MSG_ONE, g_MsgId_WeaponList, .player = player );
{
write_string( WEAPON_NEW ); // WeaponName
write_byte( -1 ); // PrimaryAmmoID
write_byte( -1 ); // PrimaryAmmoMaxAmount
write_byte( -1 ); // SecondaryAmmoID
write_byte( -1 ); // SecondaryAmmoMaxAmount
write_byte( SLOT - 1 ); // SlotID (0...N)
write_byte( 1 ); // NumberInSlot (1...N)
write_byte( CSW_KNIFE ); // WeaponID
write_byte( 0 ); // Flags
}
message_end();
}
}
public OnItemSlotKnife()
{
SetHamReturnInteger(SLOT);
return HAM_SUPERCEDE;
}
/* ANOTHER WAY
public plugin_precache ( )
{
register_message(get_user_msgid("WeaponList"), "msgWeaponList");
}
public msgWeaponList ( msgID, msgDest, id )
{
if( get_msg_arg_int(8) == CSW_C4 )
{
set_msg_arg_string ( 1 , "weapon_tripmine" ) ;
set_msg_arg_int ( 3 , ARG_BYTE, get_pcvar_num ( g_pTripMax ) ) ;
}
} */