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
user = {}
grenades = {51,52,53,54,72,73,75,76,86}
function onJoin(id)
	user[id] = {}
end
function onLeave(id)
	user[id] = nil
end
function onSelect(id,item)
	user[id].last = nil
	if isGrenade(id,item) then
		user[id].last = item
	end
end
function onAttack(id)
	-- you have to check the function to don't get nil
	if user[id].last then
		msg2(id,getLastAttackGrenade(id))
	end
end
function isGrenade(id,item)
	for _, i in pairs(grenades) do
		if i == item then
			return true
		end
	end
	return false
end
function getLastAttackGrenade(id)
	if user[id].last then
		return itemtype(user[id].last,'name')
		-- returns grenade type or nil
	end
end
addhook('join','onJoin')
addhook('leave','onLeave')
addhook('select','onSelect')
addhook('attack','onAttack')