GetPlayerHealth. - 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: GetPlayerHealth. (
/showthread.php?tid=112180)
GetPlayerHealth. -
millzyman - 06.12.2009
Hey.
I am trying to finish off my freezetag game mode. But i am finding myself in a real pickle over the part that checks if the player should be frozen or not. The code is,
Код:
new Float:health;
health = GetPlayerHealth(playerid,health);
if (health<100.0)
{
PlayerFreeze(playerid,30);
}
Simple is it not?
And my PlayerFreeze script is
Код:
PlayerFreeze(playerid,seconds)
{
GFreeze[playerid]=true;
TogglePlayerControllable(playerid,0);
halt(seconds);
if (GFreeze[playerid])
{
SetPlayerHealth(playerid,0);
GFreeze[playerid]=false;
TogglePlayerControllable(playerid,1);
}
It is meant to check if the player is injured and if he is freeze him. Unfortunately for some reason when i first spawn it is just freezing me and killing me in thirty seconds. Now i know the only reason this happens is because the variable health is within 100.
My question is: What value does GetPlayerHealth(playerid,health) return, as i have read it is 1.0 and 100.0 could someone confirm which one it is or find the flaw in my coding which is causing this to happen?
Thanks much appreciated
Re: GetPlayerHealth. -
Joe Staff - 06.12.2009
You don't use GetPlayerHealth like you would GetPlayerMoney.
pawn Код:
new Float:hp
GetPlayerHealth(playerid,hp);
if(hp<=0)return SendClientMessage(playerid,0xFF0000FF,"J00 dead, suckah!!");
without modification, maximum health (at spawn) is 100.0.
Re: GetPlayerHealth. -
millzyman - 06.12.2009
Oh course thats the problem! How did i not pick that up?
Thanks alot for that, not sure how i managed to overlook that.
Re: GetPlayerHealth. -
Joe Staff - 06.12.2009
Happens to the best of us, just more often in your case.