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
SHOW_MESSAGE_WHEN_CMD_NOT_FOUND=true	-- If true then it shows "Command !<cmd> are not found!", otherwise it only being a normal say
CMD={}
COMMAND={}
T = {
	__newindex=function(_,var,val)
		rawset(CMD,var,val)
		rawset(COMMAND,var,val)
	end
}
setmetatable(CMD,T)
setmetatable(COMMAND,T}
addhook("say","CommandProcessor")
function CommandProcessor(id,txt)
	if txt:sub(1,1)=="!" then
		local Params={}
		for w in string.gmatch(txt,"%S+") do
			table.insert(Params,tonumber(w) or w)
		end
		for n,v in pairs(CMD) do
			if n==Params[1]:sub(2) then
				table.remove(Params,1)
				v(id,unpack(Params))
				return 1
			end
		end
		if SHOW_MESSAGE_WHEN_CMD_NOT_FOUND then
			msg2(id,"©255000000Command "..Params[1].." not found!")
			return 1
		end
	end
end