SA-MP Forums Archive
How to make infinity 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: How to make infinity health ? (/showthread.php?tid=200775)



How to make infinity health ? - Yaszine - 19.12.2010

Hey all,

I don't need /god
I need only, like this :

pawn Код:
new Float:health;
        GetPlayerHealth(playerid,health);
        if (health < 1000)
        {
            SetPlayerHealth(playerid, 100);
        }
    }
   
    return 1;
}
It work but if i have jumped in a loong construction (ex: Tower in LS) player will die !!
+ I need a fix health streak & sorry for my bad English
Plz ! help


Re: How to make infinity health ? - Rachael - 19.12.2010

I'm pretty sure the max health is something close to 65535, if you set a players health to this value they should be immune from collision death ( untested )


Re : How to make infinity health ? - Yaszine - 19.12.2010

Yes, but it make the health bar sign i don't need that, only i need if his health < 100 SetPlayerHealth 100 without any probs, Thx !


Re: How to make infinity health ? - Basicz - 19.12.2010

Maybe try a timer.

pawn Код:
new
Float: Health;
GetPlayerHealth ( playerid, Health );
if ( Health < 100 )
{
SetTimer ( "RefillHealth", 1000, 0 );
return 1;
}

// Add it in a blank line ( Not in callbacks I mean ).
forward RefillHealth ( );
public RefillHealth ( )
{
SetPlayerHealth ( playerid, 100.0 );
return 1;
}
Sorry if it will not work, because I didn't test it.


Re: How to make infinity health ? - hanzen - 19.12.2010

You could run it in OnPlayerUpdate() tho it will be ran very often.

Edit: This will fuck up your script..
Код:
new Float:health;
        GetPlayerHealth(playerid,health);
        if (health < 1000)
        {
            SetPlayerHealth(playerid, 100);
        }
    }
   
    return 1;
}
Remember health is a Float. Also this will set your health to 100 like all the time, should probably add a zero(0) at the SetPlayerHealth().


Re: How to make infinity health ? - [TD]Torben - 19.12.2010

Or get a gamemode and type /sethp <user> 999999.


Re: How to make infinity health ? - Hiddos - 19.12.2010

Why not simply use OnPlayerUpdate for things like this?

pawn Код:
public OnPlayerUpdate(playerid)
{
  new Float:HP; GetPlayerHealth(playerid, HP);
  if(HP < 1000) SetPlayerHealth(playerid, 1000);
  return 1;
}



Re: How to make infinity health ? - Mean - 19.12.2010

Quote:
Originally Posted by Basicz
Посмотреть сообщение
Maybe try a timer.

pawn Код:
new
Float: Health;
GetPlayerHealth ( playerid, Health );
if ( Health < 100 )
{
SetTimer ( "RefillHealth", 1000, 0 );
return 1;
}

// Add it in a blank line ( Not in callbacks I mean ).
forward RefillHealth ( );
public RefillHealth ( )
{
SetPlayerHealth ( playerid, 100.0 );
return 1;
}
Sorry if it will not work, because I didn't test it.
That would work, but you need to use
SetTimerEx("RefillHealth", 1000, 1, "i", playerid);
you mistaked 2 things here, repeating, and you should use SetTimerEx


Re : Re: How to make infinity health ? - Yaszine - 19.12.2010

Quote:
Originally Posted by Basicz
Посмотреть сообщение
pawn Код:
new
Float: Health;
GetPlayerHealth ( playerid, Health );
if ( Health < 100 )
{
SetTimer ( "RefillHealth", 1000, 0 );
return 1;
}
Where can I put this, OnPlayerUpdate ?!


Re: How to make infinity health ? - WillyP - 19.12.2010

Quote:
Originally Posted by Yaszine
Посмотреть сообщение
Where can I put this, OnPlayerUpdate ?!
Quote:
Originally Posted by Hiddos
Посмотреть сообщение
Why not simply use OnPlayerUpdate for things like this?

pawn Код:
public OnPlayerUpdate(playerid)
{
  new Float:HP; GetPlayerHealth(playerid, HP);
  if(HP < 1000) SetPlayerHealth(playerid, 1000);
  return 1;
}
Use Hiddy's.

Also, if you were using Basicz, by the time the timer kicks in, if you were getting shot at by a minigun, you would already be dead.