Cómo se hace

Create a command in FiveM with RegisterCommand

Learn to create /coords, /heal or admin commands in FiveM with RegisterCommand, server-authoritative and with ACE permission control.

The problem

You want to add your own command (player or admin) that is secure and not exploitable from the client.

The cause

A command that gives an advantage (heal, money, admin teleport) must run and be validated on the SERVER. If you do it only on the client, anyone can trigger it.

The solution

Player command (client) and permission-gated command (server):

lua
-- Client: harmless command (prints coords)
RegisterCommand('coords', function()
    local c = GetEntityCoords(PlayerPedId())
    print(('x=%.2f y=%.2f z=%.2f'):format(c.x, c.y, c.z))
end, false)

-- Server: admin command (restricted by ACE)
RegisterCommand('curar', function(src)
    if src > 0 and not IsPlayerAceAllowed(src, 'command.curar') then return end
    TriggerClientEvent('mi_recurso:client:curar', src)
end, true)

Step by step

  1. 1.Use RegisterCommand on the client for harmless actions (info, opening a UI).
  2. 2.For actions that give an advantage, put it on the SERVER and validate with IsPlayerAceAllowed.
  3. 3.Grant the permission via ACE in server.cfg: `add_ace group.admin command.curar allow`.
  4. 4.Never trust client data: validate amounts and targets on the server.

Different case?

Paste your error in the AI tool and get the fix instantly.

Try the tool

Related guides

Last updated: 2026-06-19. Crxative-M is not affiliated with Cfx.re or Rockstar Games.

How to create a command in FiveM (RegisterCommand) with permissions