Regenerate HP
#1

Hello, how can i make that a team regenerates +2 hp in 3 seconds?
Reply
#2

Create a timer
Reply
#3

Any example?
Reply
#4

pawn Код:
#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;
}
P.S: No tested
Reply
#5

If to do that their health is going to go up forever. They'll end up on like 4748485 health and will be pretty much invincible.

Also, in this circumstance a single timer with a loop may be better.
Reply
#6

So how do you make it stop when he reach 100% of health?
Reply
#7

Quote:
Originally Posted by gotwarzone
Посмотреть сообщение
So how do you make it stop when he reach 100% of health?
like this
(gonna use ytimers)
pawn Код:
//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;
}
additional note:i didn't code for months but the code should be okey, i guess...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)