Why this plugin isn't working properly ?
when I'm holding a knife it should restore my Health every 10 seconds, but it doesn't.
code:
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <fun>
#include <cstrike>
#define PLUGIN "knife heal"
#define VERSION "1.0"
#define AUTHOR "addinol"
new gtime, gmax, gadd
public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR)
register_event("CurWeapon", "Event_CurWeapon", "be","1=1");
gtime = register_cvar("inch_khptime","10.0")
gmax = register_cvar("inch_khpmax","200")
gadd = register_cvar("inch_khprestore","3")
}
public Event_CurWeapon(id)
{
new clip, ammo, weapon = get_user_weapon(id,clip,ammo);
if(weapon == CSW_KNIFE) {
set_task(get_pcvar_float(gtime), "hp")
}
}
public hp(id){
new userHp = get_user_health(id)
if(userHp >= get_pcvar_num(gmax))
{
set_user_health(id, get_pcvar_num(gmax))
}else{
set_user_health(id, userHp + get_pcvar_num(gadd))
set_task(get_pcvar_float(gtime), "hp")
}
}