Advertisement
Hiddos

HidBar 1.1

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