SA-MP Forums Archive
Know how Much Health Player Have? - 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: Know how Much Health Player Have? (/showthread.php?tid=281180)



Know how Much Health Player Have? - ServerScripter - 04.09.2011

Hi , i want to know how to Creat like a text in the Top of the Screen say that :

Health : TheHealthOfPlayer

thanx


Re: Know how Much Health Player Have? - Darnell - 04.09.2011

Create3DTextLabel, Attach3DTextLabelToPlayer, Update3DTextLabelText.


Re: Know how Much Health Player Have? - [MWR]Blood - 04.09.2011

Use GetPlayerHealth:
https://sampwiki.blast.hk/wiki/GetPlayerHealth
Then, create a textdraw, create a public function where you will set the textdraw's string, finally do a timer that will call that function
Example:
pawn Код:
new Text:Textdraw;

//under OnGameModeInit
SetTimer("UpdateHealth",3000,true);//setting up the timer that will call the function
//Your textdraw create code here..


//under OnPlayerSpawn
TextDrawShowForPlayer(playerid,Textdraw);


//anywhere in your gamemode(not in any callback)
forward UpdateHealth(playerid);
public UpdateHealth(playerid)
{
    new Float:health, string[20];
    GetPlayerHealth(playerid,health);
    format(string,sizeof(string),"Health: %03f",health);
    TextDrawSetString(Textdraw,string);
    return 1;
}



Re: Know how Much Health Player Have? - Phanto90 - 04.09.2011

Or maybe a textdraw. He hasn't been very much descriptive D:


Re: Know how Much Health Player Have? - Hellhound - 04.09.2011

Use new Float:X,Float:Y Etc...
Then GetPlayerPos(playerid, X,Y,Z)
and Format it.... format(Var, sizeof(Var) " <Text> %f %f %f", X,Y,Z);
Then GameTextForPlayer(playerid, Var, 5000, 1);


Re: Know how Much Health Player Have? - ServerScripter - 04.09.2011

Quote:
Originally Posted by [MWR]Blood
Посмотреть сообщение
Use GetPlayerHealth:
https://sampwiki.blast.hk/wiki/GetPlayerHealth
Then, create a textdraw, create a public function where you will set the textdraw's string, finally do a timer that will call that function
Example:
pawn Код:
new Text:Textdraw;

//under OnGameModeInit
SetTimer("UpdateHealth",3000,true);//setting up the timer that will call the function
//Your textdraw create code here..


//under OnPlayerSpawn
TextDrawShowForPlayer(playerid,Textdraw);


//anywhere in your gamemode(not in any callback)
forward UpdateHealth(playerid);
public UpdateHealth(playerid)
{
    new Float:health, string[20];
    GetPlayerHealth(playerid,health);
    format(string,sizeof(string),"Health: %03f",health);
    TextDrawSetString(Textdraw,string);
    return 1;
}
Your Code is without Warnings/Errors
but Don't Working i can't see My health IG...


Re: Know how Much Health Player Have? - [MWR]Blood - 04.09.2011

Well, are you sure you created your textdraw, and the names are exactly the same everywhere?


Re: Know how Much Health Player Have? - Darnell - 04.09.2011

Quote:
Originally Posted by ServerScripter
Посмотреть сообщение
Your Code is without Warnings/Errors
but Don't Working i can't see My health IG...
You won't see YOUR OWN health, other players will see it above you.


Re: Know how Much Health Player Have? - ServerScripter - 04.09.2011

I folowed all you sayed step by step,

and to explain more, i want all players see their Health .


Re: Know how Much Health Player Have? - [MWR]Blood - 04.09.2011

Quote:
Originally Posted by Darnell
Посмотреть сообщение
You won't see YOUR OWN health, other players will see it above you.
He should be able to see his health as I made it in a textdraw.

@ServerScripter: Are you sure your textdraw isn't created somewhere out of the screen?
What tool did you use to create it?