try:
PHP Code:
#include <amxmodx>
#include <fun>
#define TASK_REGEN 328479239
new max_hp, hp_time, hp_give, regen_hp[33]
public plugin_init()
{
register_plugin("VIP REGENERATOR", "1.0", "AMXMODX")
max_hp = register_cvar("HR_maxhp", "140")
hp_time = register_cvar("HR_hptime", "2.0")
hp_give = register_cvar("HR_hpgive", "2")
register_clcmd("say /reg", "generate_hp")
}
public generate_hp(id)
{
if(!task_exists(id + TASK_REGEN))
{
set_task(get_pcvar_float(hp_time), "regen", id + TASK_REGEN, _, _, "b")
regen_hp[id] = 0
}
}
public regen(taskid)
{
new id = taskid - TASK_REGEN
if(!is_user_alive(id) || regen_hp[id] == 40)
{
remove_task(taskid)
return
}
new health = get_user_health(id)
new maxhp = get_pcvar_num(max_hp)
new hpgive = get_pcvar_num(hp_give)
if((health + hpgive) >= maxhp)
{
set_user_health(id, maxhp)
remove_task(taskid)
}
else
{
set_user_health(id, health + hpgive)
regen_hp[id] += hpgive
}
}