1
2
3
4
5
6
7
8
function totable(t,match)
local cmd = {}
if not match then match = "[^%s]+" end
for word in string.gmatch(t, match) do
table.insert(cmd, word)
end
return cmd
end
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
function lvl(id)
	local filename = "server_data/"..player(id,"usgn")..".txt"
	local file = io.open(filename)
	if file then
		for line in file:lines() do
			local parses = totable(line)
			if parses[1] ~= nil then
				if parses[1] == "member" then
					return 1
				elseif parses[1] == "mod" then
					return 2
				elseif parses[1] == "gamemaster" then
					return 3
				elseif parses[1] == "admin" then
					return 4
				end
			else
				return 0
			end
		end
		if file ~= nil then
			file:close()
		end
	end
	return 0
end