ServersYour serverFor creatorsForumFAQDocumentationSecurity
Download the launcher
  1. Documentation
  2. Server functions
  3. getBuiltinCommands

Function

getBuiltinCommands

ServerInput and controlsTrilogy Hub only

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