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
51
52
53
54
55
56
57
58
59
60
--mod_gg.lua
init_mod("gg")
gg.var("wpnlvl", {}, "svar")
gg.var("players", {}, "svar")
gg.var("maxlvl", 0)
gg.var("minlvl", 0)
function gg.setlevel(p, level, b)
	if b then
		msg("Player \""..player(p, "name").."\" is now on level "..level)
	end
	gg.players[p].level = level
	gg.players[p].kills = 0
	setWeapon(p, gg.wpnlvl[level].wpn_id)
end
function hook_init_gg()
	for line in io.lines(conf_dir.."gungame.cfg") do
		local r = toTable(line)
		gg.wpnlvl[tonumber(r[1])] = {wpn_name = r[2],wpn_id = _G[r[2]], kills = tonumber(r[3])}
		if tonumber(r[1]) > gg.maxlvl then
			gg.maxlvl = tonumber(r[1])
		elseif tonumber(r[1]) < gg.minlvl then
			gg.minlvl = tonumber(r[1])
		end
	end
	for i = 1, 32, 1 do
		gg.players[i] = {level = 0, kills = 0}
	end
end
function hook_startround_gg(typ)
	for i = 1, 32, 1 do
		gg.players[i] = {level = 0, kills = 0}
	end
	for i=1, #players, 1 do
		if player(i, "health") > 0 then
			gg.setlevel(i, 1)
		end
	end
end
function hook_changeteam_gg(p, t)
	gg.players[p].kills = 0
	gg.players[p].level = gg.players[p].level - 1
	if gg.players[p].level < 1 then gg.players[p].level = 1 end
	gg.setlevel(p, gg.players[p].level)
end
function hook_leave_gg(p, t)
	gg.players[p] = {level = 0, kills = 0}
end
function hook_join_gg(p, t)
	gg.setlevel(p, 1)
end
function hook_kill_gg(k, v, w)
	if gg.players[k].level > gg.maxlvl or gg.players[k].level <= gg.minlvl then return nil end
	if w == gg.wpnlvl[gg.players[k].level].wpn_id then
		gg.players[k].kills = gg.players[k].kills + 1
	end
	if gg.players[k].kills >= gg.wpnlvl[gg.players[k].level].kills then
		gg.setlevel(k, gg.players[k].level+1, true)
	end
end
return gg.name
which is exactly 60 lines and includes backwards leveling for switching teams and ability to set custom levels, kills to advance levels, and to curtail the minimum and maximum levels.1
2
3
4
5
6
7
8
9
10
11
12
13
All	Player 2 has been killed by Player 1 with 40
All	Player 1 has been killed by Player 2 with 40
All	Player 2 has been killed by Player 1 with 40
All	Player "Player 1" is now on level 2
All	Player 3 has been killed by Player 2 with 40
All	Player "Player 2" is now on level 2
All	Player 3 has been killed by Player 1 with 33
All	Player 4 has been killed by Player 2 with 33
All	Player 2 has been killed by Player 1 with 33
All	Player "Player 1" is now on level 3
All	Player 4 has been killed by Player 1 with 31
All	Player 2 has been killed by Player 1 with 31
All	Player "Player 1" is now on level 4