Know how Much Health Player Have?
#1

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

Health : TheHealthOfPlayer

thanx
Reply
#2

Create3DTextLabel, Attach3DTextLabelToPlayer, Update3DTextLabelText.
Reply
#3

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;
}
Reply
#4

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

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);
Reply
#6

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

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

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

I folowed all you sayed step by step,

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

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?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)