FiveM Docs
Core Resources

esx_whitelist

Set up esx_whitelist for ESX Legacy. Identifier and Discord role whitelist, admin-only mode, bypass list, in-game panel, commands, config and SQL.

esx_whitelist controls who can connect to an ESX Legacy server. It checks players during playerConnecting against a database identifier list, Discord guild roles, or both, and adds an admin-only maintenance mode, an emergency bypass list, Discord webhook logging and an in-game admin panel. It ships disabled, so installing it changes nothing until you enable it.

Overview

FactValue
Resourceesx_whitelist
SideServer (connection check) + client (admin panel NUI)
Dependenciesoxmysql, esx_lib, es_extended
Databaseesx_whitelist_config, esx_whitelist_identifiers (created automatically)
Version1.16.3 (shipped with ESX Legacy 1.16.4)

Installation

Import the SQL (optional)

Import whitelist.sql. The resource also creates missing tables and indexes on start, so this step is optional.

Add convars and ensure the resource

Secrets must use set (server only). UI convars must use setr so the client can read them.

server.cfg
set discord:botToken "YOUR_DISCORD_BOT_TOKEN"            # only for discord/both mode
set whitelist:webhook "https://discord.com/api/webhooks/..." # optional logging
setr esx:ui:logoUrl "https://example.com/logo.png"         # optional panel logo

ensure oxmysql
ensure esx_lib
ensure es_extended
ensure esx_whitelist

Configure and enable

Edit config/main.lua: pick a Mode, add identifiers or Discord roles, then set Config.Whitelist.Enabled = true. You can also do all of this later in the /whitelist panel.

Never put the bot token in config or client files

The token is read only from the discord:botToken convar. Keep it out of config/main.lua (it is a shared script and is sent to clients) and out of public repositories.

How a connection is checked

Every connection runs through the same order. The first matching rule decides:

0. Whitelist disabled            -> allow
1. Bypass identifiers            -> allow        (method: bypass)
2. Admin-only mode enabled       -> allow/deny   (skips everything below)
3. Cached admin group            -> allow        (method: admin_group)
4. Mode-specific check           -> allow/deny
5. Default                       -> deny         (fail closed)
ModeBehavior
identifierOne of the player's identifiers is in the whitelist list.
discordThe player has a linked Discord identifier, is a member of GuildId, and has at least one role from AllowedRoles.
both + CombinationMode = 'or'Identifier match or Discord verification.
both + CombinationMode = 'and'Identifier match and Discord verification.

Admin groups are read from the group column of the ESX users table (matched via the esx:identifier convar, default license) and updated live on esx:playerLoaded and esx:setGroup. If the database is not ready within 15 seconds, the player is rejected with a verification error.

Configuration

All keys live in config/main.lua. Values changed in the panel are saved to esx_whitelist_config and override the file.

General

KeyDefaultDescription
Config.LocaleGetConvar('esx:locale', 'en')Language. Only en ships with the resource.
Config.IdentifierTypes{ license2 = true, license = true, fivem = true }Identifier prefixes accepted for access lists. ip is always rejected.
Config.DebugfalsePrint extra logs to the server console.

Config.Whitelist

KeyDefaultDescription
EnabledfalseMaster switch. When false, everyone may connect and no checks run.
Mode'identifier''discord', 'identifier' or 'both'.
CombinationMode'or'How both combines the checks: 'or' or 'and'.
AllowedIdentifiers{}Initial identifier list, imported once into esx_whitelist_identifiers (type whitelist).

Config.Discord

KeyDefaultDescription
EnabledfalsePerform Discord verification.
GuildId''Discord server id the player must be a member of.
AllowedRoles{}Role ids; the member needs at least one.
Timeout5000Per-request HTTP timeout (ms).
CacheTTL60Seconds a verified result may be reused. 0 disables the cache.
CacheMaxEntries10000Max cached Discord results.
RequestsPerSecond40Outbound request smoothing, in addition to Discord rate-limit headers.
MaxRetries2Retries for timeouts, 5xx and network errors.
RetryBaseDelay750First retry delay (ms), doubled per attempt.
RetryMaxDelay4000Max retry delay (ms).

Config.Admin

KeyDefaultDescription
Groups{ admin = true, superadmin = true, owner = true }ESX groups that may use the panel and commands, and that bypass the normal whitelist.
IdentifierPriority{ 'license2', 'license', 'fivem' }Order used to pick the stable identifier for cache keys.
Cache.EnabledtrueEnable the admin group cache.
Cache.SaveDelay5000Kept for panel compatibility. Admin decisions are not persisted.

Config.AdminOnly

KeyDefaultDescription
EnabledfalseMaintenance mode: only these groups or identifiers may connect.
Groups{ admin = true, superadmin = true, owner = true }Groups allowed in admin-only mode.
AllowedIdentifiers{}Identifiers allowed in admin-only mode (imported once, type admin_only).

Config.Bypass

KeyDefaultDescription
AllowedIdentifiers{}Emergency list checked before everything else, even admin-only mode (imported once, type bypass). Keep it tiny.

Config.Logging

The webhook URL comes from the whitelist:webhook convar.

KeyDefaultDescription
EnabledtrueSend events to the webhook (only if the convar is set).
MinInterval1200Minimum ms between webhook requests.
BatchSize5Events sent per cycle.
QueueLimit250Max queued events; the oldest are dropped.
Levels{ info = true, warning = true, error = true, security = true }Severities that are sent.

Config.Performance

KeyDefaultDescription
DiscordConcurrency10Max simultaneous Discord API requests.
DiscordQueueLimit4096Max pending Discord verifications.
VerificationTimeout120000Hard limit (ms) for one connection check.
PanelRateLimit10Panel actions allowed per window.
PanelRateWindow5000Rate-limit window (ms).

Config.Panel

KeyDefaultDescription
Command'whitelist'Command name for the panel and subcommands.
SubcommandsPanel = 'panel', Status = 'status', Reload = 'reload', Cache = 'cache', CacheClear = 'clear', Test = 'test', Add = 'add', Remove = 'remove'Names of the subcommands.

Commands

All commands work in the server console. In-game, the player's ESX group must be in Config.Admin.Groups; unauthorized attempts are logged as security events.

CommandDescription
/whitelist or /whitelist panelOpen the admin panel (in-game only).
whitelist statusMode, admin-only state, Discord readiness and decision counters.
whitelist reloadReload runtime config and admin cache from the database, clear the Discord cache.
whitelist cacheCache and queue statistics.
whitelist cache clearClear the Discord verification cache.
whitelist test <serverId>Run the full check against an online player.
whitelist add <identifier> [type]Add an identifier. type is whitelist (default), admin_only or bypass.
whitelist remove <identifier> [type]Remove an identifier from that list.
Server console
whitelist add license2:1234567890abcdef1234567890abcdef12345678
whitelist add license:abcdef1234567890abcdef1234567890abcdef12 bypass
whitelist status

Admin panel

/whitelist opens a NUI panel with the tabs Dashboard, Whitelist, Discord, Admins and Logging & Performance. Changes are validated on the server, rate limited, persisted to esx_whitelist_config and logged. The panel refuses changes to admin groups that would remove your own current group, so you cannot lock yourself out. Theme convars: esx:ui:logoUrl, esx:ui:primaryColor, esx:ui:secondaryColor, esx:ui:backgroundColor, esx:ui:accentColor (all setr).

Discord bot setup

  1. Create an application and bot at the Discord developer portal.
  2. Invite the bot to your guild with the bot scope. No special permissions are required; role checks use the guild member endpoint.
  3. Enable Developer Mode in Discord, then copy the guild id and role ids into GuildId and AllowedRoles (or the panel).
  4. Set Config.Discord.Enabled = true and Config.Whitelist.Mode = 'discord' or 'both'.

Players must have Discord running and linked to FiveM, otherwise they have no discord: identifier and are denied.

Database schema

whitelist.sql
CREATE TABLE IF NOT EXISTS `esx_whitelist_config` (
  `setting_key` VARCHAR(64) NOT NULL,
  `setting_value` LONGTEXT NOT NULL,
  `updated_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`setting_key`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS `esx_whitelist_identifiers` (
  `identifier` VARCHAR(128) NOT NULL,
  `type` VARCHAR(32) NOT NULL DEFAULT 'whitelist',
  `created_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`identifier`, `type`),
  KEY `idx_type` (`type`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

type is one of whitelist, admin_only or bypass.

Exports and events

esx_whitelist has no public exports. Its net events (prefix esxwl:) are internal to the panel and command bridge. It listens to playerConnecting, playerDropped, esx:playerLoaded and esx:setGroup.

Common issues

Frequently asked questions

Independent documentation

esx-fivem.com is a community project and is not affiliated with the ESX Framework team. Facts on this page were checked against the upstream source. Official resources: docs.esx-framework.org and github.com/esx-framework.
Edit on GitHub

Last updated on

On this page