SHOW:
|
|
- or go back to the newest paste.
1 | - | // Name: HidBar |
1 | + | |
2 | - | // Author: Hiddos |
2 | + | |
3 | - | // Date: 21st March 2011 |
3 | + | |
4 | - | // Version: 1.1 |
4 | + | print("\n--------------------------------------"); |
5 | - | // Don't re-release without permission. |
5 | + | print(" HidBar 1.2 loaded to the server"); |
6 | print("--------------------------------------\n"); | |
7 | return 1; | |
8 | - | #define HITCOLOR 0xFF0000FF |
8 | + | |
9 | - | #define MAX_HEALTH_LENGTH 2 |
9 | + | |
10 | public OnFilterScriptExit() | |
11 | - | new Float:old_hp[MAX_PLAYERS]; |
11 | + | |
12 | - | new Float:old_ap[MAX_PLAYERS]; |
12 | + | for(new i = 0; i != MAX_PLAYERS; i++) |
13 | { | |
14 | - | public OnPlayerUpdate(playerid) |
14 | + | if(IsPlayerConnected(i)) |
15 | { | |
16 | - | new Float:new_hp, Float:new_ap; |
16 | + | new Text3D:hitbar = Text3D:(GetPVarInt(i, "hidbar_HitBar") - 1); |
17 | - | GetPlayerArmour(playerid, new_ap); |
17 | + | if(_:hitbar != -1) |
18 | - | GetPlayerHealth(playerid, new_hp); |
18 | + | { |
19 | - | if(new_hp >= old_hp[playerid] && new_ap >= old_ap[playerid]) |
19 | + | Delete3DTextLabel(hitbar); |
20 | DeletePVar(i, "hidbar_HitBar"); | |
21 | - | old_hp[playerid] = new_hp; |
21 | + | } |
22 | - | old_ap[playerid] = new_ap; |
22 | + | } |
23 | - | return 1; |
23 | + | |
24 | } | |
25 | - | new Text3D:hitbar; |
25 | + | |
26 | public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid) | |
27 | - | new diff = floatround( (old_hp[playerid] - new_hp) + (old_ap[playerid] - new_ap) ); |
27 | + | |
28 | - | new string[MAX_HEALTH_LENGTH + 1]; |
28 | + | new str[4]; |
29 | new Float:Pos[3]; | |
30 | - | format(string, sizeof string, "%i", diff); |
30 | + | |
31 | - | hitbar = Create3DTextLabel(string, HITCOLOR, Pos[0], Pos[1], Pos[2] + 0.6, 30.0, 0); |
31 | + | format(str, 4, "%.1f", amount); |
32 | - | SetTimerEx("UpdateHitBar", 66, 0, "iifffii", _:hitbar, diff, Pos[0], Pos[1], Pos[2] + 0.8, 16, HITCOLOR); |
32 | + | new Text3D:hitbar = Create3DTextLabel(str, 0xFF0000FF, Pos[0], Pos[1], Pos[2] + 0.6, 30.0, 0); |
33 | - | old_hp[playerid] = new_hp; |
33 | + | SetTimerEx("UpdateHitBar", 66, 0, "iffffii", playerid, amount, Pos[0], Pos[1], Pos[2] + 0.8, 16, 0xFF0000FF); |
34 | - | old_ap[playerid] = new_ap; |
34 | + | SetPVarInt(playerid, "hidbar_HitBar", _:hitbar + 1); |
35 | return 1; | |
36 | } | |
37 | ||
38 | forward UpdateHitBar(playerid, Float:hp, Float:x, Float:y, Float:z, update_no, color); | |
39 | public UpdateHitBar(playerid, Float:hp, Float:x, Float:y, Float:z, update_no, color) | |
40 | - | for(new i; i < MAX_PLAYERS; i++) |
40 | + | |
41 | new Text3D:hitbar = Text3D:(GetPVarInt(playerid, "hidbar_HitBar") - 1); | |
42 | - | GetPlayerHealth(i, old_hp[i]); |
42 | + | Delete3DTextLabel(hitbar); |
43 | - | GetPlayerArmour(i, old_ap[i]); |
43 | + | update_no--; |
44 | if(!update_no) | |
45 | { | |
46 | DeletePVar(playerid, "hidbar_HitBar"); | |
47 | return; | |
48 | - | public OnPlayerConnect(playerid) |
48 | + | |
49 | ||
50 | - | old_hp[playerid] = 100.0; |
50 | + | new string[4]; |
51 | - | old_ap[playerid] = 0.0; |
51 | + | z += 0.05; |
52 | color -= 12; | |
53 | format(string, sizeof string, "%.1f", hp); | |
54 | hitbar = Create3DTextLabel(string, color, x, y, z, 30.0, 0); | |
55 | - | forward UpdateHitBar(Text3D:hitbar, hp, Float:x, Float:y, Float:z, update_no, color); |
55 | + | SetTimerEx("UpdateHitBar", 66, 0, "iffffii", playerid, hp, x, y, z, update_no, color); |
56 | - | public UpdateHitBar(Text3D:hitbar, hp, Float:x, Float:y, Float:z, update_no, color) |
56 | + | SetPVarInt(playerid, "hidbar_HitBar", _:hitbar + 1); |
57 | } |