OK...here is what I have.
Code:
if(equali(szClassname, "healer"))
{
if(get_user_health(id) >= 100)
return 1;
else
set_task(2.0,"give_health",id,_,_,"b");
}
Code:
public give_health(id)
{
new hp = get_user_health(id);
if(hp >= 99)
{
client_print(id, print_chat, "Debug: Setting user hp to 100");
set_user_health(id, 100);
remove_task(id);
return 1;
}
client_print(id, print_chat, "Debug: Adding 2 hp. Current HP = %d", hp);
set_user_health(id, hp+2);
return 1;
}
Works...BUT...doesn't call the function every 2 seconds.
I get this in console.
Debug: Adding 2 hp. Current HP = 81
Debug: Adding 2 hp. Current HP = 83
Debug: Adding 2 hp. Current HP = 85
Debug: Adding 2 hp. Current HP = 87
Debug: Adding 2 hp. Current HP = 89
Debug: Adding 2 hp. Current HP = 91
Debug: Adding 2 hp. Current HP = 93
Debug: Adding 2 hp. Current HP = 95
Debug: Adding 2 hp. Current HP = 97
Debug: Setting user hp to 100
REAL FAST...but it does take 2 second to start.
ALSO. If you die, and you land on the block it does this...
Debug: Adding 2 hp. Current HP = -122
Debug: Adding 2 hp. Current HP = -122
Debug: Adding 2 hp. Current HP = -122
Debug: Adding 2 hp. Current HP = -122
Debug: Adding 2 hp. Current HP = -122
Debug: Adding 2 hp. Current HP = -122
Debug: Adding 2 hp. Current HP = -122
Debug: Adding 2 hp. Current HP = -122
...SPAMS THIS HARD CORE...until this
Debug: Adding 2 hp. Current HP = 1
Debug: Adding 2 hp. Current HP = 3
Debug: Adding 2 hp. Current HP = 5
Debug: Adding 2 hp. Current HP = 7
Debug: Adding 2 hp. Current HP = 9
...
Debug: Adding 2 hp. Current HP = 99
Debug: Setting user hp to 100
Help fix those two things ?