14.05.2012, 17:02
Use three textdraws
The calculation is the easiest thing
- The first is the border
- The second one would be the whole bar just a bit darker as the real bar
- And the last would be the real bar
The calculation is the easiest thing
pawn Code:
new
Float: health
;
GetPlayerHealth(playerid, health);
/*
100 hp = 50 px // 50 is the size of the bar
health = x px // x would be the calculated size
x = health * 50 / 100 = health * 0.5 = health / 2
*/
TextDrawTextSize(
textdraw,
150.0 + (health / 2), // 150.0 is start position of the textdraw
3.6
); // TextDrawTextSize doesnt update the textdraw, so we show it again to the player
TextDrawShowForPlayer(playerid, textdraw);