1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
local screenx, screeny = 640, 480 local health_x, health_y = 98 + 6, screeny - (6 + 4) function drawhudhealth (id) 	if (not PLAYER.hud[id].health_bar) then 		PLAYER.hud[id].health_bar = image (DIRECTORY.gfx .. "bar.png", health_x, health_y, 2, id) 	end 	 	if (not PLAYER.hud[id].health_overlay) then 		PLAYER.hud[id].health_overlay = image (DIRECTORY.gfx .. "overlay.png", health_x, health_y, 2, id) 	end 	 	updatehudhealth (id) end function updatehudhealth (id) 	local scale = player (id, "health") / player (id, "maxhealth") 	 	local green = scale * 255 	local red = 255 - green 	local blue = 0 	 	imagescale (PLAYER.hud[id].health_bar, scale, 1) 	imagecolor (PLAYER.hud[id].health_bar, red, green, blue) 	imagepos (PLAYER.hud[id].health_bar, health_x * scale, health_y, 0) end -- HOOKS function hud_spawn (id) 	drawhudhealth (id) end function hud_die (victim) 	freeimage (PLAYER.hud[victim].health_bar) 	freeimage (PLAYER.hud[victim].health_overlay) end function hud_always () 	for key, id in pairs (player (0, "tableliving")) do 		updatehudhealth (id) 	end end local hooks = {"spawn", "die", "always", "collect"} for key, hook in pairs (hooks) do 	addhook (hook, "hud_" .. hook) end