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
addhook("hit", "_hit")
addhook("die", "_die")
addhook("spawn", "_spawn")
addhook("leave", "_leave")
local images = {}
function removeImages(id)
images[id] = images[id] or {}
for i = 1, #images[id] do
freeimage(images[id][i])
end
images[id] = {}
end
function _hit(id, source, wpn, hpdmg)
removeImages(id)
local newHP = tostring(player(id, "health") - hpdmg)
for i = 1, #newHP do
local img = image("gfx/numbers/"..newHP:sub(i,i)..".png", 0, 0, 2, id)
imagepos(img, 320 + (i-1) * 50, 240, 0)
table.insert(images[id], img)
end
end
function _spawn(id)
_hit(id, 0, 0, 0)
end
function _die(id)
removeImages(id)
end
function _leave(id)
removeImages(id)
end