Admin Permissions
How to become admin in ESX Legacy, using users.group, /setgroup, ACE permissions in server.cfg, Config.CommandPermissions and custom admin-only commands.
To become admin in ESX Legacy, set your ESX group to admin: run setgroup <yourServerId> admin in the server console, or set users.group to admin in the database while you are offline. ESX then links that group to FiveM's ACE system (group.admin), which is what actually unlocks the admin commands, so server.cfg also needs the ACE lines shown below.
Overview
ESX permissions have two layers that work together:
| Layer | Stored in | Used for |
|---|---|---|
| ESX group | users.group (default user) | xPlayer.getGroup(), scripts that check groups, the Player(source).state.group state bag |
| ACE principal | Added at runtime by es_extended | FiveM command permissions (command.setjob and so on) |
When a player loads, es_extended runs add_principal identifier.<license> group.<esxGroup>. When you change the group with /setgroup or xPlayer.setGroup(), it removes the old principal and adds the new one. Every command registered with ESX.RegisterCommand gets an add_ace group.<group> command.<name> allow entry for each allowed group.
The default groups are user, admin and owner. The column is free text, so you can invent more, but each group needs entries in Config.CommandPermissions to be useful. A group named superadmin is converted to admin when the player loads.
Required server.cfg lines
These lines come with the official txAdmin recipe and server.cfg. If you set up the server by hand, check that they exist:
add_principal group.admin group.user
add_ace group.admin command allow # allow all commands
add_ace group.admin command.quit deny # but don't allow quit
add_ace resource.es_extended command.add_ace allow
add_ace resource.es_extended command.add_principal allow
add_ace resource.es_extended command.remove_principal allow
add_ace resource.es_extended command.stop allowThe resource.es_extended lines let es_extended run add_ace, add_principal and remove_principal itself. Without them, ESX groups never turn into ACE permissions and admin commands are denied even when the database says admin.
Make yourself admin
Join the server once
ESX creates your row in users on first join. Note your server ID (txAdmin player list, or the scoreboard).
Set the group from the console
In the server console or the txAdmin live console, without a slash:
setgroup 1 adminThe arguments are [playerId] [group]. In game, an existing admin can run /setgroup me admin or /setgroup 5 owner. The group is applied immediately; it is written to the database on the next player save (every 10 minutes, on disconnect, or with /save [playerId]).
Verify
Run /group in game. The command prints your current group to the server console. In scripts, read xPlayer.getGroup().
Alternative: edit the database
With the player offline, update the row directly. The identifier is the Rockstar license hash without the license: prefix; with esx_multicharacter it is prefixed with the character slot, for example char1:.
UPDATE `users` SET `group` = 'admin' WHERE `identifier` = 'char1:1a2b3c4d5e6f...';Do this only while the player is offline. An online player's group lives in memory and is saved back on the next save, which would overwrite your change.
Alternative: admin on first join through ACE
When a new player row is created, es_extended checks IsPlayerAceAllowed(source, 'command'). If the player already has ACE access to command (for example through an add_principal identifier.license:... group.admin line in server.cfg), they are created with group admin. The txAdmin recipe adds such lines for the txAdmin master account ({{addPrincipalsMaster}}), which is why the server owner is often admin automatically. This only affects new characters; existing ones keep their stored group.
add_principal identifier.license:1a2b3c4d5e6f... group.adminOn a local test server with sv_lan set to true, every player counts as admin.
Config.CommandPermissions
In es_extended/shared/config/main.lua, Config.CommandPermissions maps each built-in command to the groups that may use it:
Config.CommandPermissions = {
["setjob"] = { "owner", "admin" },
["car"] = { "owner", "admin" },
["noclip"] = { "owner", "admin" },
["job"] = { "user", "admin", "owner" },
-- ...
}To let a mod group use /goto and /bring but nothing else:
["goto"] = { "owner", "admin", "mod" },
["bring"] = { "owner", "admin", "mod" },Then setgroup <id> mod. A command without an entry is restricted to admin with a console warning.
Config.AdminGroups (owner and admin) is marked deprecated in 1.16.4 but is still read by xPlayer.isAdmin(). Keep it in sync if third-party scripts rely on it.
Built-in admin commands
All of these accept me as the player ID in game. Most also work from the server console.
| Command | Arguments | What it does |
|---|---|---|
/setgroup | playerId group | Change ESX group |
/setjob | playerId job grade | Change job (Create a job) |
/giveaccountmoney | playerId account amount | Add money to money, bank or black_money |
/setaccountmoney / /removeaccountmoney | playerId account amount | Set or remove account money |
/giveitem | playerId item count | Give an item (default inventory only) |
/giveweapon, /giveammo, /giveweaponcomponent | Weapons (default inventory only) | |
/car, /cardel (/dv), /fix (/repair) | Spawn, delete, repair vehicles | |
/setcoords (/tp), /tpm, /goto, /bring | Teleporting | |
/noclip, /kill, /freeze, /unfreeze | Player control | |
/setdim (/setbucket) | Routing bucket | |
/players, /save, /saveall, /refreshjobs, /refreshitems | Server management |
With Config.AdminLogging = true and a webhook configured in the logs config, many of these commands are logged to Discord. For a full menu, see esx_adminmenu. A full list of commands is on the Commands page.
Add your own admin-only command
ESX.RegisterCommand handles the ACE setup, argument parsing and the chat suggestion for you:
ESX = exports['es_extended']:getSharedObject()
ESX.RegisterCommand('announce', { 'owner', 'admin' }, function(xPlayer, args, showError)
if #args.message < 3 then
return showError('Message too short')
end
TriggerClientEvent('chat:addMessage', -1, {
args = { 'Announcement', args.message },
})
end, true, {
help = 'Send a server-wide announcement',
arguments = {
{ name = 'message', help = 'Text to send', type = 'merge' },
},
})| Argument | Description |
|---|---|
name | Command name, or a table of aliases like { 'announce', 'ann' } |
group | Group name or list of groups allowed to run it |
cb | function(xPlayer, args, showError); xPlayer is false when run from the console |
allowConsole | true to allow the server console |
suggestion | help, arguments (types: number, player, playerId, string, item, weapon, coordinate, merge, any) and optional validate = true to require the exact argument count |
To check permissions in your own events, read the group on the server, never trust the client:
RegisterNetEvent('myresource:adminAction', function()
local xPlayer = ESX.GetPlayerFromId(source)
if not xPlayer or xPlayer.getGroup() ~= 'admin' then
return
end
-- privileged code
end)Common issues
The add_ace resource.es_extended ... lines are missing from server.cfg, or another resource removed the principal. Restart after adding the lines.
You edited the database while the player was online, and the in-memory group was saved back over it. Use /setgroup instead, or edit while offline.
/setgroup does not validate group names. A group like amdin has no permissions. Set it again with the correct name.
server.cfg only grants command allow to group.admin. owner only gets the ESX commands listed for it in Config.CommandPermissions. Add add_principal group.owner group.admin if owners should inherit everything admins have.
Related
Frequently asked questions
Independent documentation
Last updated on
Add Items
How to add items in ESX Legacy, with the items table SQL, weight, rare and can_remove, ESX.AddItems, usable items via ESX.RegisterUsableItem and ox_inventory notes.
Money and Accounts
How money works in ESX Legacy, covering cash, bank and black_money accounts, xPlayer account methods, starting money, paychecks, society money and custom accounts.