PHP Code:
#include <amxmodx>
#include <fun>
new kill_healed, health_add, health_hs_add, health_max, nKiller, nKiller_hp, nHp_add, nHp_max
public plugin_init()
{
register_plugin("Kill Healed", "2.1", "Dev!l & [TagPro]")
register_event("DeathMsg","death","ae")
kill_healed = register_cvar("amx_killhealed", "1")
health_add = register_cvar("amx_hp", "15")
health_hs_add = register_cvar("amx_hp_hs", "25")
health_max = register_cvar("amx_hp_max", "100")
}
public death()
{
if(get_pcvar_num(kill_healed)!=1) return;
if(!is_user_connected(nKiller)) return; ///Here my added check
// Killer id
nKiller = read_data(1)
// Change HP Amount when made a Head Shot
if (read_data(3)==1 && read_data(5)==0)
nHp_add = get_pcvar_num(health_hs_add)
else
nHp_add = get_pcvar_num(health_add)
// Updating Killer HP
nHp_max = get_pcvar_num (health_max)
nKiller_hp = get_user_health(nKiller) + nHp_add
// Check Maximum HP
if (nKiller_hp > nHp_max) nKiller_hp = nHp_max
set_user_health(nKiller, nKiller_hp)
// Hud message "Healed +25/+50 hp"
set_hudmessage(0, 255, 0, -1.0, 0.15, 0, 1.0, 1.0, 0.1, 0.1, -1)
show_hudmessage(nKiller,"Healed +%d HP",nHp_add)
// Screen fading
message_begin(MSG_ONE,get_user_msgid("ScreenFade"),{0,0,0},nKiller)
write_short(1<<10)
write_short(1<<10)
write_short(0x0000)
write_byte(0) // red
write_byte(0) // green
write_byte(200) // blue
write_byte(75) // alpha
message_end()
}
The plugin give me this error;
HTML Code:
L 02/10/2018 - 13:04:30: [FUN] Player out of range (0)
L 02/10/2018 - 13:08:09: [AMXX] Displaying debug trace (plugin "kill_healed.amxx", version "2.1")
L 02/10/2018 - 13:08:09: [AMXX] Run time error 10: native error (native "set_user_health")
L 02/10/2018 - 13:08:09: [AMXX] [0] kill_healed.sma::death (line 40)
I was added is_user_connected check at line 19, but still got error, how can i fix error?