02.03.2014, 16:36
Hello, how can i make that a team regenerates +2 hp in 3 seconds?
#include <a_samp>
/////////////////
forward RegenHP(playerid);
public OnPlayerSpawn(playerid)
{
SetTimerEx("RegenHP",3000,true,"i",playerid);
return 1;
}
public RegenHP(playerid)
{
SetPlayerHealth(playerid,GetPlayerHealth(playerid)+2);
return 1;
}
//global timer var
new Timer:health_T[MAX_PLAYERS];//declaring a timer var
//start the timer from somewhere.. idk.. maybe a command?
health_T[playerid] = repeat health(playerid);//asign that repeat timer's id to the player var
//the timer itself, !outside! just like a function, that's what these timers are
timer health[3000](playerid)//getting called for that player every 3 seconds
{
new float:ckh;
GetPlayerHealth(playerid,ckh);
if(ckh > 100)
{
SetPlayerHealth(playerid,100);//set it to 100, cuz it might be 101. You can cut that out ofc since the difference between 100 and 101 isn't rly much
stop health_T[playerid];//stop the timer
}
else
{
SetPlayerHealth(playerid,ckh+2);
}
return 1;
}