I don't get it why I get this error.
Code:
L 08/16/2014 - 11:06:15: [CSTRIKE] Non-player entity 0 out of range
L 08/16/2014 - 11:06:15: [AMXX] Displaying debug trace (plugin "trainpcw.amxx")
L 08/16/2014 - 11:06:15: [AMXX] Run time error 10: native error (native "cs_get_weapon_ammo")
L 08/16/2014 - 11:06:15: [AMXX] [0] trainpcw.sma::eDeath (line 9999999)
PHP Code:
public eDeath()
{
new iKiller = read_data(1);
new iVictim = read_data(2);
new szKillMSG[50];
new weapon_id = fm_find_ent_by_owner(-1, weapon_weapon, iKiller);
if( IsPlayer(iKiller) && is_user_alive(iKiller) && Tonly[iKiller])
{
if( iVictim != iKiller)
{
switch( cs_get_weapon_ammo(weapon_id) )
{
case 0: formatex(szKillMSG, charsmax(szKillMSG), "K");
case 1: formatex(szKillMSG, charsmax(szKillMSG), "P");
}
set_hudmessage(0, 255, 0, -1.0, 0.4, 0, 6.0, 2.5, 0.0, 0.0, -1);
show_hudmessage(iKiller, szKillMSG);
if( is_user_alive(iKiller) )
{
if( weapon_id )
{
if( cs_get_weapon_ammo(weapon_id) == 0 )
{
cs_set_weapon_ammo(weapon_id, 1);
}
}
}
}
}
return PLUGIN_HANDLED;
}