SA-MP Forums Archive
refill health - 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: refill health (/showthread.php?tid=346305)



refill health - sanrock - 27.05.2012

I made an admin class.
But how do I make the admin player heal refill after every 1 secound?

so it like infinit health?


Re: refill health - mati233 - 27.05.2012

You can do it simply, just like this:
PHP код:
public OnPlayerUpdate(playerid){
    if(
IsPlayerAdmin(playerid)) SetPlayerHealth(playerid100);




Re: refill health - FalconX - 27.05.2012

Quote:
Originally Posted by n00b_scripter
Посмотреть сообщение
SetTimer("AdminClass",1000,1);
forward AdminClass();
public AdminClass();
{
//your health refill codes here
}
For making the indentation more better and also with pawn tags:-

pawn Код:
forward AdminRefillHealth();// in top


SetTimer("AdminRefillHealth", 1000, true); // put where ever you want maybe in a command or somewhere else like gamemodeinit


public AdminRefillHealth()
{
    for(new f = 0; f < MAX_PLAYERS; f++) // making loop
    {
        if(IsPlayerConnected(f))
        {
            if(IsPlayerAdmin(f)) // change this to your var if you want. this is a default RCON admins.
            {
                SetPlayerHealth(f, 100);
            }
        }
    }
}
but timers would be a bad idea because if you use more timers it will waste your more memory/CPU try something like OnPlayerTakeDamage?

I hope this helps
-FalconX


Re: refill health - IceCube! - 27.05.2012

Why not use OnPlayerTakeDamage? it then doesnt waste resources on a stupid timer!

public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid)


Re: refill health - iggy1 - 27.05.2012

Better to just god mode em.


Re: refill health - FalconX - 27.05.2012

Quote:
Originally Posted by iggy1
Посмотреть сообщение
Better to just god mode em.
true that xD

pawn Код:
SetPlayerHealth(playerid, 999999); // o_o
Regards FalconX


Re: refill health - Tanush123 - 28.05.2012

Quote:
Originally Posted by FalconX
Посмотреть сообщение
true that xD

pawn Код:
SetPlayerHealth(playerid, 999999); // o_o
Regards FalconX
with 999999 health it won't make the person god because imagine you had 999999 health and i have a minigun, i could shoot you and you could die around 10 seconds. But it will work if you make a timer which sets your health 999999 every second