Help with Health regen - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Help with Health regen (
/showthread.php?tid=114042)
Help with Health regen -
mister_ic3 - 17.12.2009
this is the code i am using and it works fine but it allways sets the players health to 0 when the player spawns then starts to regen the health
Код:
public HealthRegen(playerid)
{
new Float:health;
GetPlayerHealth(playerid,health);
if (health < 100)
{
SetPlayerHealth(playerid, health +1);
// SendClientMessage(playerid, COLOR_RED, "DEBUG :- HEALTH REGEN !");
}
}
i dont want it to set it to 0 as i have health and armour saving
could someone please take a look and give me a clue on where i have gone wrong or even point me in the right direction i have searched and only found the GTO one which is what i based this on.
Re: Help with Health regen -
admantis - 17.12.2009
Quote:
Originally Posted by mister_ic3
this is the code i am using and it works fine but it allways sets the players health to 0 when the player spawns then starts to regen the health
Код:
public HealthRegen(playerid)
{
new Float:health;
GetPlayerHealth(playerid,health);
if (health < 100)
{
SetPlayerHealth(playerid, health +1);
// SendClientMessage(playerid, COLOR_RED, "DEBUG :- HEALTH REGEN !");
}
}
i dont want it to set it to 0 as i have health and armour saving
could someone please take a look and give me a clue on where i have gone wrong or even point me in the right direction i have searched and only found the GTO one which is what i based this on.
|
Try...
Код:
OnPlayerSpawn(playerid)
{
SetPlayerHealth(playerid,100)
}
maybe that?
Re: Help with Health regen -
Vincent_r - 18.12.2009
you can make a Timer
e.g: every minute (60*1000 = 60 sec)
Код:
SetTimer("health_regen",60*1000,true);
Код:
public health_regen(playerid)
{
new Float:health;
GetPlayerHealth(playerid,health);
if (health < 100) //
{
SetPlayerHealth(playerid,health+1);
}
}
and don't forget to put
Код:
forward health_regen(playerid)
at the top of your script
-Vince
Re: Help with Health regen -
Calon - 18.12.2009
I'm sure that you can't use floats any more in SetPlayerHealth, use floatround() to round it and use an integer, I saw it on the wiki a while ago but it seems someone has edited that.
Here's the method I use:
Код:
new Float: PlHealth;
GetPlayerHealth(playerid, PlHealth);
new MathsFlaw = floatround(PlHealth, floatround_ceil);
SetPlayerHealth(playerid, MathsFlaw+1);
Re: Help with Health regen -
Joe Staff - 18.12.2009
That's only for NPCs. a_player's SetPlayerHealth still uses floats.
pawn Код:
public HealthRegen(playerid)
{
if(GetPlayerState(playerid)=PLAYER_STATE_WASTED)return;
new Float:health;
GetPlayerHealth(playerid,health);
if (health < 100)SetPlayerHealth(playerid, health +1);
}
Try something like that.
Re: Help with Health regen -
Calon - 18.12.2009
Quote:
Originally Posted by Joe Staff
That's only for NPCs. a_player's SetPlayerHealth still uses floats.
|
Ah, right.
Re: Help with Health regen -
Vincent_r - 18.12.2009
Quote:
Originally Posted by Joe Staff
pawn Код:
public HealthRegen(playerid) { if(GetPlayerState(playerid)=PLAYER_STATE_WASTED)return; new Float:health; GetPlayerHealth(playerid,health); if (health < 100)SetPlayerHealth(playerid, health +1); }
|
one equal sign "=" is missing
Re: Help with Health regen -
mister_ic3 - 20.12.2009
Thank you for all the replys i will go and try them now
EDIT :- sorry no luck it's still setting the health to 0 when i log in

nevermind i will try to sort it out thanks again