GetPlayerHealth.
#1

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
Reply
#2

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.
Reply
#3

Oh course thats the problem! How did i not pick that up?

Thanks alot for that, not sure how i managed to overlook that.
Reply
#4

Happens to the best of us, just more often in your case.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)