Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Name: HidBar
- // Author: Hiddos
- // Date: 21st March 2011
- // Don't re-release without permission.
- #include <a_samp>
- #define HITCOLOR 0xFF0000FF
- #define MAX_HEALTH_LENGTH 2
- new Float:old_hp[MAX_PLAYERS];
- public OnPlayerUpdate(playerid)
- {
- new Float:new_hp;
- GetPlayerHealth(playerid, new_hp);
- if(new_hp >= old_hp[playerid])
- {
- old_hp[playerid] = new_hp;
- return 1;
- }
- new Text3D:hitbar;
- new Float:Pos[3];
- new string[MAX_HEALTH_LENGTH + 1];
- GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
- format(string, sizeof string, "%i", floatround(old_hp[playerid] - new_hp));
- hitbar = Create3DTextLabel(string, HITCOLOR, Pos[0], Pos[1], Pos[2] + 0.6, 30.0, 0);
- SetTimerEx("UpdateHitBar", 66, 0, "iifffii", _:hitbar, floatround(old_hp[playerid] - new_hp), Pos[0], Pos[1], Pos[2] + 0.8, 16, HITCOLOR);
- old_hp[playerid] = new_hp;
- return 1;
- }
- public OnFilterScriptInit() for(new i; i < MAX_PLAYERS; i++) GetPlayerHealth(i, old_hp[i]);
- public OnPlayerConnect(playerid) old_hp[playerid] = 100.0;
- forward UpdateHitBar(Text3D:hitbar, hp, Float:x, Float:y, Float:z, update_no, color);
- public UpdateHitBar(Text3D:hitbar, hp, Float:x, Float:y, Float:z, update_no, color)
- {
- Delete3DTextLabel(hitbar);
- update_no--;
- if(!update_no) return;
- new string[MAX_HEALTH_LENGTH + 1];
- z += 0.05;
- color -= 12;
- format(string, sizeof string, "%i", hp);
- hitbar = Create3DTextLabel(string, color, x, y, z, 30.0, 0);
- SetTimerEx("UpdateHitBar", 66, 0, "iifffii", _:hitbar, hp, x, y, z, update_no, color);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement