SA-MP Forums Archive
Regenerate HP - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Regenerate HP (/showthread.php?tid=498255)



Regenerate HP - Blackazur - 02.03.2014

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


Re: Regenerate HP - Clad - 02.03.2014

Create a timer


AW: Regenerate HP - Blackazur - 02.03.2014

Any example?


Re: Regenerate HP - Psyhophatic - 02.03.2014

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


Re: Regenerate HP - MP2 - 03.03.2014

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.


Re: Regenerate HP - gotwarzone - 03.03.2014

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


Re: Regenerate HP - CutX - 03.03.2014

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...