Skip to content
GAMPEONCreate
New project
Preview: this works today, but details can still change.

Commands

Console and chat commands that resources register, and permissions (ACE) for them.

RegisterCommand(commandName, handler, restricted?)

Add a command for the console, the chat (/name) or key bindings. Server and client.

Commands are shared by all resources on the same side. If two resources register the same name, the later one wins and a warning is logged. Commands of a stopped resource are removed.

Parameter Type Description
commandName string Name without slash, for example “car”. Not case-sensitive.
handler fun(source: integer, args: string[], rawCommand: string) Called with the player ID (0 for the server console), the words after the command and the whole line.
restricted (optional) boolean If true, only players with the permission command.<name> may use it (see add_ace in server.cfg).
RegisterCommand('heal', function(source, args, raw)
local target = tonumber(args[1]) or source
TriggerClientEvent('myres:heal', target)
end, true)

Compared to FiveM: Same as in FiveM. The handler runs in its own thread, so it may call Wait.

ExecuteCommand(commandString)

Run a console command, as if typed into the server console. Server and client.

Parameter Type Description
commandString string The whole command line, for example “restart myresource”.
ExecuteCommand('add_principal identifier.gampeon:42 group.admin')

Compared to FiveM: Same as in FiveM. On the server it runs with console permissions; built-in commands like start, stop or add_ace work too.

GetRegisteredCommands() --> {name: string, resource: string, arity: integer, restricted: boolean}[]

List all commands that resources registered on this side. Server and client.

Returns

  • {name: string, resource: string, arity: integer, restricted: boolean}[]: One entry per command. arity is always -1. restricted is true for commands that need an ACE permission.
for _, cmd in ipairs(GetRegisteredCommands()) do
print(cmd.name, cmd.resource)
end

Compared to FiveM: Same as in FiveM.

IsPlayerAceAllowed(playerSrc, object) --> boolean

Check if a player has a permission (ACE). Server only.

Parameter Type Description
playerSrc integer|string Player ID.
object string Permission, for example “command.heal” or “myres.admin”.

Returns

  • boolean: true if allowed.
if IsPlayerAceAllowed(source, 'myres.admin') then
-- ...
end

Compared to FiveM: Same as in FiveM. Server operators grant permissions with add_ace and add_principal in server.cfg.

Report a problem with this pageOther ways to give feedback