FiveM Docs

Introduction to ESX Legacy

What ESX Legacy is, how the FiveM framework is built (es_extended, core resources, addons, oxmysql, OneSync) and how this independent documentation is organized.

ESX Legacy is an open-source roleplay framework for FiveM, the GTA V multiplayer platform. It gives your server a persistent player object with money accounts, jobs, an inventory and permission groups, plus a set of ready-made resources (character creation, menus, jobs, shops, banking) that you can use as they are or replace with your own.

This site documents ESX Legacy 1.16.4 (current release as of October 2026). Everything here is checked against the Lua source in esx-framework/esx_core. When the official docs and the source disagree, this site follows the source.

Independent documentation

esx-fivem.com is a community project and is not affiliated with the ESX team. The official documentation lives at docs.esx-framework.org and the source code at github.com/esx-framework. Report framework bugs on the official GitHub, not here.

A short history

ESX started in 2017 as a framework that added jobs, money accounts and an inventory to FiveM servers. It quickly became one of the most common bases for FiveM roleplay servers, and a large ecosystem of free and paid scripts grew around it.

The original ESX releases were written for a much older FiveM: no OneSync, Lua 5.3, mysql-async and many client-trusted events. ESX Legacy is the continued, actively maintained line of the framework. It keeps the familiar API (ESX.GetPlayerFromId, xPlayer.addMoney, esx:playerLoaded and so on) so that most older scripts still work, but it modernizes the internals:

  • oxmysql instead of mysql-async / ghmattimysql
  • Lua 5.4 (lua54 'yes') in every core resource
  • OneSync Infinity is required, which allows server-side entity and player lookups
  • a shared library resource, esx_lib, that provides callbacks, validation, rate limiting and other helpers to the core
  • automatic database migrations when you update the core
  • many security fixes, for example events that only accept calls from es_extended itself

If you find a tutorial that uses TriggerEvent('esx:getSharedObject', ...) or mysql-async, it was written for old ESX. See Convert old ESX scripts for how to update it.

Architecture

An ESX Legacy server is a normal FiveM server with a few layers of resources. They start in this order:

LayerResourcesRole
Database driveroxmysqlConnects FiveM to MariaDB or MySQL. Every ESX resource queries the database through it.
Libraryesx_libShared helpers used by es_extended (callbacks, schema helpers, OneSync helpers, validation).
Corees_extendedThe framework itself: player objects (xPlayer), accounts, jobs, items, commands, callbacks, paychecks.
Core resourcesesx_identity, esx_multicharacter, esx_skin, skinchanger, esx_notify, esx_textui, esx_progressbar, esx_context, esx_menu_*, esx_inventory, esx_whitelist, esx_loadingscreen, esx_chat_theme, cronUI, character creation and other systems that most servers need. They ship in the [core] folder.
Addonsesx_policejob, esx_ambulancejob, esx_banking, esx_shops, esx_vehicleshop, esx_property and moreOptional gameplay resources from the [esx_addons] folder in ESX-Legacy-Addons.
Your scriptsanything you writeGet the ESX object through @es_extended/imports.lua or exports['es_extended']:getSharedObject().

The most important idea is the player object. When a player has loaded, the server holds an xPlayer for them. You get it with ESX.GetPlayerFromId(source) and call methods on it, for example xPlayer.addAccountMoney('bank', 500, 'Salary'). ESX keeps that state in memory and saves it to the users table. On the client, the same data is mirrored in ESX.PlayerData.

server/main.lua
local ESX = exports['es_extended']:getSharedObject()

RegisterNetEvent('myscript:hello', function()
    local xPlayer = ESX.GetPlayerFromId(source)
    if not xPlayer then return end

    xPlayer.showNotification(('Hello %s, you work as %s'):format(xPlayer.getName(), xPlayer.job.label))
end)

Requirements at a glance

  • A current FiveM server build (ESX refuses connections on artifacts older than 10188)
  • OneSync set to on (Infinity). off and legacy are rejected when a player connects.
  • MariaDB (recommended) or MySQL
  • oxmysql and esx_lib started before es_extended

Who this documentation is for

How this site is organized

Conventions used on this site

  • Code examples use Lua 5.4 and the modern way of getting ESX (@es_extended/imports.lua or the getSharedObject export).
  • Every function has its side marked: server, client or shared. Calling a server function on the client (or the other way round) is the most common cause of attempt to call a nil value errors.
  • source always means the server ID of the player who triggered an event or command.
  • Each page lists its upstream source file, so you can check the code yourself.

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