Also client_death is the name of a csx forward, you should use another name for this event.
I would use pcvars and fakemeta.
Code:
#include <amxmodx>
#include <fakemeta>
#define PLUGIN "Health on frag"
#define VERSION "1.0"
#define AUTHOR "TheLinx"
#define OFFSET_TEAM 114
#define user_team(%1) get_pdata_int(%1, OFFSET_TEAM)
// pcvars holders
new healthonfrag_enabled, healthonfrag_health, healthonfrag_health_extra_hs, healthonfrag_health_max
// max players var
new g_max_clients
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
healthonfrag_enabled = register_cvar("amx_healthonfrag_enabled", "1")
healthonfrag_health = register_cvar("amx_healthonfrag_health", "0")
healthonfrag_health_extra_hs = register_cvar("amx_healthonfrag_health_extra_hs", "25")
healthonfrag_health_max = register_cvar("amx_healthonfrag_health_max", "175")
register_event("DeathMsg", "eDeathMsg", "a", "1>0")
}
public plugin_cfg()
{
// get max players
g_max_clients = global_get(glb_maxClients)
}
public eDeathMsg() // this is a global event so you need to check id's below
{
if(!get_pcvar_num(healthonfrag_enabled)) // plugin is disabled
return
new killer = read_data(1)
if(killer > g_max_clients) // killer is not a player (entity)
return
new victim = read_data(2)
if(user_team(victim) == user_team(killer)) // team kill
return
new headshot = read_data(3) // 1 = headshot, 0 = normal kill
new Float:health_to_give
switch(headshot)
{
case 0:health_to_give = get_pcvar_float(healthonfrag_health)
case 1:health_to_give = get_pcvar_float(healthonfrag_health_extra_hs)
}
if(!health_to_give)
return
new Float:health
pev(killer, pev_health, health)
new Float:max_health = get_pcvar_float(healthonfrag_health_max)
if(health == max_health)
return
if(max_health - health_to_give > health)
set_pev(killer, pev_health, health + health_to_give)
else
set_pev(killer, pev_health, max_health)
}