How do i automatically update players health? - 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: How do i automatically update players health? (
/showthread.php?tid=144376)
How do i automatically update players health? -
Typical_Cat - 26.04.2010
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?
Re: How do i automatically update players health? -
_Vortex - 26.04.2010
Get the player's health again, and reset the text draw.
Re: How do i automatically update players health? -
dcmd_crash - 26.04.2010
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?