I've only included part of the code but it should be enough to see what my problem is. Right now it's in first slot, first spot - and here it works. But when I try to redirect it to any other slot/spot it just disappears and nothing is on my HUD besides my regular weapons. I'd like to know what I am doing wrong with this to cause the problem. Some people have reported that the weapon appears above and below their primary weapon, for me it is only above the primary weapon (where according to the code it should be - but there is probably something wrong). I'd like to know if you could offer some help.
Something else is when an attack is made with this weapon it says "C4 must be planted at a bomb site!" and I want to remove this. Currently the code that I have doesn't work.
Would be much appreciated!
PHP Code:
public plugin_init()
{
register_message(get_user_msgid("TextMsg"), "Message_TextMsg")
register_clcmd("weapon_NemBaz", "ClientCommand_SelectNemBaz")
RegisterHam(Ham_Item_AddToPlayer, "weapon_c4", "OnAddToPlayerNemBaz", .Post = true)
RegisterHam(Ham_Item_ItemSlot, "weapon_c4", "OnItemSlotNemBaz")
}
public plugin_precache()
{
precache_generic("sprites/weapon_NemBaz.txt")
precache_generic("sprites/640hud19.spr")
precache_generic("sprites/640hud20.spr")
}
public ClientCommand_SelectNemBaz( const client )
{
engclient_cmd( client, "weapon_c4" );
}
public OnAddToPlayerNemBaz( const item, const player )
{
if( pev_valid( item ) && is_user_alive( player ) && flag_get(g_Isevilnem, player)) // just for safety.
{
message_begin( MSG_ONE, MsgIndexWeaponList, .player = player );
{
write_string("weapon_NemBaz"); // WeaponName
write_byte( -1 ); // PrimaryAmmoID
write_byte( -1 ); // PrimaryAmmoMaxAmount
write_byte( -1 ); // SecondaryAmmoID
write_byte( -1 ); // SecondaryAmmoMaxAmount
write_byte( 0 ); // SlotID (0...N) <== Changed here (was 2)
write_byte( 1 ); // NumberInSlot (1...N)
write_byte( CSW_C4 ); // WeaponID
write_byte( 0 ); // Flags
}
message_end();
}
}
public OnItemSlotNemBaz( const item )
{
SetHamReturnInteger(5);
return HAM_SUPERCEDE;
}
public Message_TextMsg(iMsgId, iMsgDest, id)
{
if( !id && get_msg_arg_int(1) == print_center )
{
new szMessage[64]
get_msg_arg_string(2, szMessage, charsmax(szMessage))
if( equal(szMessage, "C4 must be planted at a bomb site!") )
{
return PLUGIN_HANDLED
}
}
return PLUGIN_CONTINUE
}
weapon_NemBaz.txt:
PHP Code:
2
weapon 640 640hud19 0 135 170 45
weapon_s 640 640hud20 0 135 170 45