EN · $ USD
FiveM Scripts and Development

How to Convert an ESX Script to QBCore

7 min read Updated: OyunBulut technical team

In short

To convert an ESX script to QBCore, you replace framework calls with their equivalents: GetCoreObject instead of getSharedObject, Functions.GetPlayer instead of GetPlayerFromId, AddMoney('cash') instead of addMoney, AddItem instead of addInventoryItem, and CreateCallback instead of RegisterServerCallback. Identifier and users references in SQL must become citizenid and players, and item and job definitions must move into the shared files.

In this guide
  1. Before you start converting
  2. ESX to QBCore function equivalents
  3. Example: Converting a selling script
  4. Recommended conversion order
  5. 9 things most often missed when converting
  6. A cleaner approach: A bridge file
  7. Testing checklist
  8. Speed up the conversion or hand it off
  9. What's next

Converting an ESX script to QBCore means changing the lines where the script talks to the framework, not its game logic: getting the core object, the player object, money, inventory, jobs, callbacks and event names. In this guide we give you one-to-one equivalents for these functions in tables, walk through a real conversion example and list the spots people miss most often.

Before you start converting

ESX and QBCore do the same job with different data models. ESX stores players by identifier in the users table; QBCore generates a citizenid for each character and uses the players table. Money types, job grades and item definitions also live in different places. That's why "find and replace" conversions often don't throw errors at startup but cause silent bugs in game, like money not being deducted or items not being given.

If you haven't weighed the general differences between the two frameworks yet, we recommend reading our ESX vs. QBCore vs. QBox comparison. Before you begin:

  1. Make sure the script isn't encrypted with escrow; encrypted files can't be converted, and only bridge files left open can be adapted.
  2. Back up the original folder and do the conversion on a separate test server.
  3. Note the script's SQL file and its fxmanifest.lua dependencies.

ESX to QBCore function equivalents

Core object and player

ActionESXQBCore
Get the core objectexports['es_extended']:getSharedObject()exports['qb-core']:GetCoreObject()
Player object (server)ESX.GetPlayerFromId(src)QBCore.Functions.GetPlayer(src)
Persistent IDxPlayer.identifierPlayer.PlayerData.citizenid
Player data (client)ESX.GetPlayerData()QBCore.Functions.GetPlayerData()
Player loaded (client event)esx:playerLoadedQBCore:Client:OnPlayerLoaded
Job changed (client event)esx:setJobQBCore:Client:OnJobUpdate

Money

ActionESXQBCore
Read cashxPlayer.getMoney()Player.PlayerData.money.cash
Add cashxPlayer.addMoney(n)Player.Functions.AddMoney('cash', n, 'sebep')
Remove cashxPlayer.removeMoney(n)Player.Functions.RemoveMoney('cash', n, 'sebep')
Read bankxPlayer.getAccount('bank').moneyPlayer.PlayerData.money.bank
Add to bankxPlayer.addAccountMoney('bank', n)Player.Functions.AddMoney('bank', n, 'sebep')
Dirty moneyxPlayer.addAccountMoney('black_money', n)No default account; the markedbills item is usually used

Inventory and items

ActionESXQBCore
Give itemxPlayer.addInventoryItem(ad, adet)Player.Functions.AddItem(ad, adet)
Remove itemxPlayer.removeInventoryItem(ad, adet)Player.Functions.RemoveItem(ad, adet)
Item countxPlayer.getInventoryItem(ad).countPlayer.Functions.GetItemByName(ad) and .amount
Usable itemESX.RegisterUsableItem(ad, fn)QBCore.Functions.CreateUseableItem(ad, fn)
Item definitionDatabase items table (classic ESX)qb-core/shared/items.lua

Jobs, callbacks and notifications

ActionESXQBCore
Job namexPlayer.job.namePlayer.PlayerData.job.name
Job gradexPlayer.job.gradePlayer.PlayerData.job.grade.level
On dutyNo defaultPlayer.PlayerData.job.onduty
Define server callbackESX.RegisterServerCallback(ad, fn)QBCore.Functions.CreateCallback(ad, fn)
Trigger callback (client)ESX.TriggerServerCallback(ad, cb, ...)QBCore.Functions.TriggerCallback(ad, cb, ...)
Notification (client)ESX.ShowNotification(msg)QBCore.Functions.Notify(msg, 'success')
Notification (server)xPlayer.showNotification(msg)TriggerClientEvent('QBCore:Notify', src, msg, 'error')

Example: Converting a selling script

Below is simple ESX server code that sells the fish a player is carrying:

ESX = exports['es_extended']:getSharedObject()

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

    local item = xPlayer.getInventoryItem('fish')
    if item and item.count > 0 then
        local kazanc = item.count * 25
        xPlayer.removeInventoryItem('fish', item.count)
        xPlayer.addMoney(kazanc)
        xPlayer.showNotification(('%d$ kazandiniz'):format(kazanc))
    end
end)

The same logic in QBCore:

local QBCore = exports['qb-core']:GetCoreObject()

RegisterNetEvent('balikci:sat', function()
    local src = source
    local Player = QBCore.Functions.GetPlayer(src)
    if not Player then return end

    local item = Player.Functions.GetItemByName('fish')
    if item and item.amount > 0 then
        local adet = item.amount
        local kazanc = adet * 25
        if Player.Functions.RemoveItem('fish', adet) then
            Player.Functions.AddMoney('cash', kazanc, 'balik-satisi')
            TriggerClientEvent('QBCore:Notify', src, ('%d$ kazandiniz'):format(kazanc), 'success')
        end
    end
end)

Note the differences: amount instead of count, the money type passed explicitly as 'cash', and the result of RemoveItem being checked. That last point matters; if the item couldn't be removed, no money should be paid out, or you create a money duplication exploit on your server.

Also, if fxmanifest.lua has ESX lines like shared_script '@es_extended/imports.lua', remove them and update the dependency:

dependencies {
    'qb-core'
}

Converting callbacks

Callbacks, where the client requests data from the server, are another common pattern. The ESX version:

-- server
ESX.RegisterServerCallback('balikci:fiyat', function(source, cb, adet)
    cb(adet * 25)
end)

-- client
ESX.TriggerServerCallback('balikci:fiyat', function(fiyat)
    ESX.ShowNotification(('Toplam: %d$'):format(fiyat))
end, 10)

The QBCore equivalent has the same structure; only the function names change:

-- server
QBCore.Functions.CreateCallback('balikci:fiyat', function(source, cb, adet)
    cb(adet * 25)
end)

-- client
QBCore.Functions.TriggerCallback('balikci:fiyat', function(fiyat)
    QBCore.Functions.Notify(('Toplam: %d$'):format(fiyat), 'primary')
end, 10)

If ox_lib is installed on your server, switching to the framework-agnostic lib.callback.register and lib.callback.await functions also makes it easier to move to another framework later.

  1. Manifest: Remove ESX imports and dependencies and add qb-core.
  2. Core object: Replace ESX definitions with QBCore in every file.
  3. Server side: Convert player, money, item and job calls using the equivalents in the tables.
  4. Client side: Convert event names, player data reads and notifications.
  5. Database: Adapt the SQL file and queries to the citizenid structure; add items and jobs to the shared files.
  6. Verify with search: When you're done, check that no lines containing ESX, xPlayer or esx: remain in the folder:
# Linux
grep -rnE "ESX|xPlayer|esx:" resources/balikci/

# Windows PowerShell
Get-ChildItem -Path .\resources\balikci -Recurse -Include *.lua | Select-String -Pattern 'ESX','xPlayer','esx:'

9 things most often missed when converting

  1. SQL queries: Queries that reference users and identifier must change to players and citizenid. owner columns in the script's own tables must also be updated to store the citizenid. We cover the database side in our oxmysql and MariaDB guide.
  2. Item definitions: Items that live in the database in ESX must be added to shared/items.lua in QBCore, or AddItem fails.
  3. Job grade type: job.grade is a number in ESX but a table in QBCore. A comparison like if job.grade >= 2 must use job.grade.level.
  4. Job definitions: Jobs stored in the jobs and job_grades tables in ESX must move to the shared/jobs.lua file in QBCore.
  5. The source variable: source can get lost in callbacks and nested functions; use local src = source on the first line of the event.
  6. Client event names: Code listening for esx:playerLoaded never fires in QBCore, and it doesn't throw an error either.
  7. Dirty money: Code that writes to the black_money account must be adapted to an item-based system in QBCore.
  8. Inventory system: If your server uses ox_inventory or a different inventory, item operations must use that inventory's exports. The names of visual events like the item box (ItemBox) also vary by inventory version.
  9. If you use QBox: QBox provides a QBCore compatibility layer, but using its own exports is the better choice for new code.

A cleaner approach: A bridge file

If you're writing a script that should run on multiple frameworks, collecting framework calls in a single bridge.lua file makes maintenance easier. For example, you write a function called Bridge.AddMoney(src, n) and inside it check which framework is loaded with GetResourceState('qb-core') == 'started'. That way only this file gets adapted, and the game logic never changes.

A simple bridge skeleton looks like this:

Bridge = {}
local QBCore, ESX

if GetResourceState('qb-core') == 'started' then
    QBCore = exports['qb-core']:GetCoreObject()
elseif GetResourceState('es_extended') == 'started' then
    ESX = exports['es_extended']:getSharedObject()
end

function Bridge.AddMoney(src, miktar)
    if QBCore then
        local Player = QBCore.Functions.GetPlayer(src)
        return Player and Player.Functions.AddMoney('cash', miktar, 'bridge')
    elseif ESX then
        local xPlayer = ESX.GetPlayerFromId(src)
        if xPlayer then xPlayer.addMoney(miktar) return true end
    end
    return false
end

Testing checklist

  • Are there no errors in the server console or F8?
  • Do money and item operations behave correctly in both success and failure cases (not enough items, full inventory)?
  • Does data persist when a player logs out and back in?
  • Do job-restricted menus open at the correct grade?
  • Did the resmon value go up after the conversion?

Speed up the conversion or hand it off

The tables above are enough for small scripts, but changing every line by hand in a system with dozens of files takes hours. Giving the mappings from the tables to an AI assistant as context and converting file by file cuts that time significantly. If you're converting several large scripts, the AI Developer Pro + plan with 3M token capacity is a good fit for that workload. You'll find how to review AI-generated code in our guide to writing FiveM scripts with AI.

For complex systems deeply tied to the economy, database or inventory, handing the job to a developer is the safer option. With OyunBulut's FiveM Developer Service, you can send the scripts to convert along with your framework version and have the conversion done for you.

What's next

Start by converting a single small script with the tables in this guide and testing it on a test server; once you've nailed the pattern, move on to the rest. If you want to move faster, compare the AI Developer plans and the developer service and choose the one that fits your workload.

Frequently asked questions

Will an ESX script run on QBCore without any changes?

Usually not. The core object, player, money and inventory functions are different, so at a minimum the framework calls need to be adapted.

What is the QBCore equivalent of the ESX identifier?

QBCore generates a citizenid for each character and stores players in the players table. Identifier references in the script's SQL queries must be replaced with citizenid.

How do you use black_money in QBCore?

QBCore has no default dirty money account. Instead, the markedbills item with a value stored on the item is most commonly used.

Can I convert an escrowed ESX script to QBCore?

Encrypted files can't be edited. Only the bridge or editable files the developer left open can be adapted; otherwise you should ask the seller for a QBCore version.

Why isn't my converted script giving items?

Most likely the item isn't defined in qb-core/shared/items.lua, or your server uses a different inventory system. Check the item definition and the inventory exports.

For this guide

Recommended plans

If you're converting many ESX scripts, the 3M token capacity of the AI Developer Pro + plan speeds up file-by-file conversion; for complex systems tied to your economy and database, you can hand the work to a developer with the Developer Service.

Dedicated developer service, weekly or monthly.

$196.62/mo

+VAT

  • LocationIstanbul
  • 5.000 TL
  • 10.000 TL
  • Automatic Setup

FiveM Services — tüm paketler

Need help with setup?

Send questions about your service in a support ticket, and our technical team will walk you through it step by step.