You could add the admin level to the passed arguments to the function:
function CheckCommand(clientNum, level, arguments)
if( arguments[0] == "!mycommand" ) then
et.trap_SendServerCommand(clientNum, "chat \"Your command "..arguments[0].." has been received\"")
return 1
end
return 0
end
function et_ClientCommand(clientNum, command)
local level = et.G_shrubbot_level(clientNum)
local flood = et.ClientIsFlooding(clientNum)
-- we're not interested if the level is too low or if the client is flooding
if (level < 1) or (flood == 1) then
return 0
end
local arg0 = string.lower(et.trap_Argv(0))
local arguments
-- check to see if the command was given through any of the chat methods or as sparse text from the console
if arg0 == "say" or arg0 == "say_team" or arg0 == "say_buddy" or arg0 == "say_teamnl" then
arguments = SplitToArguments(et.trap_Argv(1))
else
arguments = SplitToArguments(et.ConcatArgs(0))
end
-- actual command handling
return CheckCommand(clientNum, level, arguments)
end
Or you can declare the variable as close to its intended use as possible. This style is generally preferred when programming:
function CheckCommand(clientNum, arguments)
local level = et.G_shrubbot_level(clientNum)
if( (arguments[0] == "!mycommand") and (level >= 1) ) then
et.trap_SendServerCommand(clientNum, "chat \"Your command "..arguments[0].." has been received\"")
return 1
end
return 0
end
function et_ClientCommand(clientNum, command)
local flood = et.ClientIsFlooding(clientNum)
-- we're not interested if the client is flooding
if flood == 1 then
return 0
end
local arg0 = string.lower(et.trap_Argv(0))
local arguments
-- check to see if the command was given through any of the chat methods or as sparse text from the console
if arg0 == "say" or arg0 == "say_team" or arg0 == "say_buddy" or arg0 == "say_teamnl" then
arguments = SplitToArguments(et.trap_Argv(1))
else
arguments = SplitToArguments(et.ConcatArgs(0))
end
-- actual command handling
return CheckCommand(clientNum, arguments)
end