Hello, i need a little help with HP regenerator.
I want to:
player can have max 140 HP
regenerator max can add 40 HP
Something like this: if player health is 100, regenerator will increase it till 140
but if player health is 20, regenerator will increase it only till 60
im using this code
Code:
#include <amxmodx>
#include <cstrike>
#include <fun>
#include <fakemeta>
new max_hp, hp_time, hp_give
public plugin_init()
{
register_plugin("VIP REGENERATOR", "1.0", "AMXMODX")
max_hp = register_cvar("HR_maxhp", "140")
hp_time = register_cvar("HR_hptime", "2")
hp_give = register_cvar("HR_hpgive", "2")
register_clcmd("say /reg", "generate_hp")
}
public generate_hp(id)
{
new health = get_user_health(id)
if(health >= get_pcvar_num(max_hp))
{
remove_task(id)
return PLUGIN_CONTINUE
}
new hptogive = clamp(health + get_pcvar_num(hp_give), 0, get_pcvar_num(max_hp))
set_user_health(id, hptogive)
return PLUGIN_CONTINUE
}
__________________