1
2
3
4
2
3
4
commands = { {"!kick",kick_Command,rank = 2} {"!mute",mute_Command,rank = 1} }
commands = { {"!kick",kick_Command,rank = 2} {"!mute",mute_Command,rank = 1} }
-- say there's a table rank = {} -- say you load it from files and set everyone's rank to be different for example on team selection you check if there's a file with player usgn and then assign him rank[id] = what's read in the file if it exists commands = { {"!kick",DEFINE YOUR FUNCTION HERE,rank = 2} {"!mute",AND HERE,rank = 1} } -- then you check player rank like so for k,v in pairs (commands) do 	if txt == commands[v][1] then 		if rank[id] == commands[v][3] then 			commands[v][2]() -- not sure about this part 		end 	end end
owner = {140639} rank = {} for id = 1,32 do rank[id] = 0 end commands = { {"!kick",kickcmd,rank = 2}; {"!slap",slapcmd,rank = 1}; } addhook("join","setrank") function setrank(id) for _, usgn in ipairs(owner) do if player(id,"usgn") == usgn then rank[id] = 3 end end end function kickcmd(id,iid,rsn) if not rsn then rsn = "No reason specified" msg(player(id,"name").." kicked "..player(iid,"name").." for: "..rsn) parse("kick "..iid.." "..rsn) end end function slapcmd(id,iid) parse("slap "..iid) end addhook("say","_say") function _say(id,t) for k, v in pairs(commands) do if t == commands[v][1] then if rank[id] >= commands[v][3] then commands[v][2]() end return 1 end msg2(id,"Error,invalid command!") end end
LUA ERROR: sys/lua/test.lua:36: attempt to index field '?' (a nil value)
commands = { {"!kick",kickcmd,rank = 2}, {"!slap",slapcmd,rank = 1} }
v[1]
commands[v][1]
addhook("say","_say") function _say(id,t) 	local array = text_extract(t) 	for k, v in pairs(commands) do 		if array[1] == v[1] then 			if rank[id] >= v[3] then 				v[2](array[2], array[3]) 			end 			return 1 		end 	end 	msg2(id,"Error,invalid command!") end function text_extract(text) 	--[[ 		!kick 4 Used hacks 		 | 		 v 		!kick 		4 		Used hacks 	]] end
commands[v].rank ~= commands[v][3]
owner = {140639} rank = {} for id = 1,32 do rank[id] = 0 end commands = { {"!kick",kickcmd,rank = 2}; {"!slap",slapcmd,rank = 1}; } addhook("join","setrank") function setrank(id) for _, usgn in ipairs(owner) do if player(id,"usgn") == usgn then rank[id] = 3 end end end function kickcmd(id,iid,rsn) if not rsn then rsn = "No reason specified" msg(player(id,"name").." kicked "..player(iid,"name").." for: "..rsn) parse("kick "..iid.." "..rsn) end end function slapcmd(id,iid) parse("slap "..iid) end addhook("say","_say") function _say(id,t) local array = extract(t) for k, v in pairs(commands) do if array[1] == v[1] then if rank[id] >= command[v].rank then v[2](array[2],array[3]) end return 1 end msg2(id,"Error,invalid command!") end end function extract(txt) string.sub(txt) end
LUA ERROR: sys/lua/test.lua:48: bad argument #2 to 'sub'(number expected,got no value)