- Documentation
- Server functions
- getBuiltinCommands
Function
getBuiltinCommands
Returns the server's built-in commands, the ones no resource adds (e.g. me, pm, kick). With a player it returns only the commands that player may use according to admins.xml. Useful for a custom chat that recognises commands itself.
Syntax
table getBuiltinCommands([player thePlayer])Arguments
thePlayerplayer, optional- The player whose permissions to check.
Returns
A sorted table of command names, or false for a bad argument.
Example
The chat checks whether a typed command exists before passing it on.
local function commandExists(player, name)
name = name:lower()
for _, c in ipairs(getCommandHandlers()) do
if c == name then return true end
end
for _, c in ipairs(getBuiltinCommands(player)) do
if c == name then return true end
end
return false
end
See also
getCommandHandlersReturns the names of commands registered by a resource, or by every resource without an argument.executeCommandHandlerRuns a command registered withaddCommandHandleras if a player typed it. On the server you pass a player (ornil) and the arguments: a single string is split into words like in chat. On the client it runs client commands.