View Full Version : Health and Armor Textdraw

27/07/2013, 01:22 AM
Hi, i cant find any Health and Armor Textdraw well. can anyone explain or make a tutorial or make 1 i dont know how to start but i got my idea how to make it.. the health and armor will use OnPlayerUpdate? :/ can anyone explain? how will i make it c'oz im going to make a Advance Weapon System.

27/07/2013, 02:20 AM
Well, personally to create textdraws I find it much easier to use Zamaroht's Textdraw Editor (http://forum.sa-mp.com/showthread.php?t=117851) (You can find edited versions of this that allow you to also place sprites - just search the forums). You can create the textdraws how you would like, to show health/armor you can simply hide/show certain textdraws indicating the amount of health a player has (In my case, I used bars although you can show it however you would like).

And yes you can use OnPlayerUpdate, but this is called very frequently and could cause some lag. Your best option would be to create a timer (http://wiki.sa-mp.com/wiki/SetTimer), and check the health via that as you can define how often it is called.

Edit: To add on to the post below, without bumping the topic again, you could use foreach (http://forum.sa-mp.com/showthread.php?t=92679)(Which would be more efficient) to loop through the players.

27/07/2013, 06:19 AM
Try something like:

Text: textdrawid[MAX_PLAYERS];

// OnGameModeInit
timerHealth = SetTimer("UpdateHealth", 1000, true); // A repeating timer each second

//On Player Connect
textdrawid[playerid] = TextDrawCreate(...);

TextDrawShowForPlayer(playerid, textdrawid[playerid]);

//On Player Disconnect
TextDrawHideForPlayer(playerid, textdrawid[playerid]);

forward UpdateHealth();
public UpdateHealth()
Float: health[2];

for(new i = 0; i < MAX_PLAYERS; i++)
if(!IsPlayerConnected(i) || IsPlayerNPC(i)) // We don't update the health of players not connected and NPC's

GetPlayerHealth(i, health[0]);
GetPlayerArmour(i, health[1]);

format(stringHealth, sizeof(stringHealth), "Health: %.0f - Armour: %.0f", health[0], health[1]);
TextDrawSetString(textdrawid[i], stringHealth);
return 1;
Just make your own textraw to fit your needs