Advertisement
Hiddos

HidBar 1.0

Apr 22nd, 2011
588
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 1.51 KB | None | 0 0
  1. // Name:        HidBar
  2. // Author:      Hiddos
  3. // Date:        21st March 2011
  4. // Don't re-release without permission.
  5.  
  6. #include <a_samp>
  7. #define HITCOLOR 0xFF0000FF
  8. #define MAX_HEALTH_LENGTH 2
  9.  
  10. new Float:old_hp[MAX_PLAYERS];
  11.  
  12. public OnPlayerUpdate(playerid)
  13. {
  14.     new Float:new_hp;
  15.     GetPlayerHealth(playerid, new_hp);
  16.     if(new_hp >= old_hp[playerid])
  17.     {
  18.         old_hp[playerid] = new_hp;
  19.         return 1;
  20.     }
  21.     new Text3D:hitbar;
  22.     new Float:Pos[3];
  23.     new string[MAX_HEALTH_LENGTH + 1];
  24.     GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
  25.     format(string, sizeof string, "%i", floatround(old_hp[playerid] - new_hp));
  26.     hitbar = Create3DTextLabel(string, HITCOLOR, Pos[0], Pos[1], Pos[2] + 0.6, 30.0, 0);
  27.     SetTimerEx("UpdateHitBar", 66, 0, "iifffii", _:hitbar, floatround(old_hp[playerid] - new_hp), Pos[0], Pos[1], Pos[2] + 0.8, 16, HITCOLOR);
  28.     old_hp[playerid] = new_hp;
  29.     return 1;
  30. }
  31.  
  32. public OnFilterScriptInit() for(new i; i < MAX_PLAYERS; i++) GetPlayerHealth(i, old_hp[i]);
  33. public OnPlayerConnect(playerid) old_hp[playerid] = 100.0;
  34.  
  35. forward UpdateHitBar(Text3D:hitbar, hp, Float:x, Float:y, Float:z, update_no, color);
  36. public UpdateHitBar(Text3D:hitbar, hp, Float:x, Float:y, Float:z, update_no, color)
  37. {
  38.     Delete3DTextLabel(hitbar);
  39.     update_no--;
  40.     if(!update_no) return;
  41.    
  42.     new string[MAX_HEALTH_LENGTH + 1];
  43.     z += 0.05;
  44.     color -= 12;
  45.     format(string, sizeof string, "%i", hp);
  46.     hitbar = Create3DTextLabel(string, color, x, y, z, 30.0, 0);
  47.     SetTimerEx("UpdateHitBar", 66, 0, "iifffii", _:hitbar, hp, x, y, z, update_no, color);
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement