How do i automatically update players health?
#1

i made a textdraw to show the exact amount of the players health,

Code:
new Float:he;
GetPlayerHealth(playerid,he);
new string[40];
format(string, 40, "Health: %f",he);
TextDrawSetString(Textdrawhealth, string);
TextDrawShowForPlayer(playerid,Textdrawhealth);
But how do i make it automatically update?
Reply
#2

Get the player's health again, and reset the text draw.
Reply
#3

You'd have to create a function and put that function on a timer, for example:


pawn Code:
forward DrawNewHealth(playerid);
public DrawNewHealth(playerid)
{
    new Float:pHealth, string[128];
    GetPlayerHealth(playerid, pHealth);
    format(string, sizeof(string), "Health %f", pHealth);
    TextDrawSetString(TEXTDRAWNAME, string) // this is where you would update the actual textdraw
    return 1;
}
Then set that on a timer whenever you show the textdraw, maybe OnGameModeInit?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)