FiveM money types: cash, bank and black money on ESX, QBCore and QBox

How money works on FiveM: ESX accounts (money, bank, black_money), QBCore cash, bank and crypto, ox_inventory cash as an item, and the reason strings for your logs.

Players have more than one kind of money: the cash in their pocket, the bank account, and on many servers a dirty money balance. Each framework names and handles them differently, and ox_inventory adds a third way. This article shows the account names, the functions to add and remove money, how ox_inventory treats cash, and why the reason string matters.

ESX accounts

ESX has three standard accounts:

Account Meaning
money Cash
bank Bank balance
black_money Dirty money, used for illegal jobs

On the server, with the player object:

lua
ESX = exports['es_extended']:getSharedObject()
local xPlayer = ESX.GetPlayerFromId(source)

-- read
local cash = xPlayer.getAccount('money').money
local bank = xPlayer.getAccount('bank').money
local black = xPlayer.getAccount('black_money').money

-- add / remove
xPlayer.addAccountMoney('bank', 500, 'job-payout')
xPlayer.removeAccountMoney('black_money', 200, 'drug-purchase')

xPlayer.addAccountMoney(account, amount, reason) and removeAccountMoney take the account name first. For cash only, there are shortcuts:

lua
xPlayer.addMoney(100, 'sold-item')
xPlayer.removeMoney(100, 'bought-item')
local cash = xPlayer.getMoney()

removeAccountMoney does not check the balance for you. Check first, or the account can go negative on some versions:

lua
if xPlayer.getAccount('money').money >= price then
    xPlayer.removeAccountMoney('money', price, 'shop')
end

If the player object is nil, see ESX xPlayer is nil.

QBCore money

QBCore keeps its money in PlayerData.money, with cash, bank and crypto:

lua
local QBCore = exports['qb-core']:GetCoreObject()
local Player = QBCore.Functions.GetPlayer(source)

-- read
local cash = Player.PlayerData.money.cash
local bank = Player.PlayerData.money.bank

-- add / remove
Player.Functions.AddMoney('bank', 500, 'job-payout')
Player.Functions.RemoveMoney('cash', 50, 'shop-purchase')

Player.Functions.AddMoney(type, amount, reason) and Player.Functions.RemoveMoney(type, amount, reason) take the type first. RemoveMoney returns false when the player has not enough, so use the result:

lua
if Player.Functions.RemoveMoney('cash', price, 'shop-purchase') then
    Player.Functions.AddItem('burger', 1)
else
    TriggerClientEvent('QBCore:Notify', source, 'Not enough cash', 'error')
end

There is no built-in black money account in QBCore. Servers that need one usually use an item (marked bills) or a custom type added to Config.Money, and the next section covers the item option. If QBCore is nil in your script, see the GetCoreObject fix.

QBox

QBox is based on QBCore, so the same Player.Functions.AddMoney and RemoveMoney calls work on the player object, and the money types are the same. QBox also has exports on qbx_core, so check the exports of your qbx_core version for the money functions before you use them in new code. The shape is the same: a type, an amount and a reason.

ox_inventory: cash as an item

With ox_inventory, cash can be an item instead of a number. The standard item is called money, and dirty money is black_money. Both are in ox_inventory/data/items.lua.

lua
-- give cash as an item
exports.ox_inventory:AddItem(source, 'money', 500)

-- count it
local cash = exports.ox_inventory:Search(source, 'count', 'money')

-- take it
exports.ox_inventory:RemoveItem(source, 'money', 100)

-- dirty money
exports.ox_inventory:AddItem(source, 'black_money', 1000)

On an ESX server with ox_inventory, the money and black_money accounts are shown as items in the inventory, and xPlayer.addAccountMoney('money', ...) ends up in those items. Use one way only. If a script adds cash with the ESX function and another with AddItem, test that the two agree on your setup before you ship it. The bank is not an item and stays a number.

Warning: cash as an item has weight and can be dropped, stolen or stored in a stash. This is intended, but it changes how robbery and shop scripts behave. See stashes in ox_inventory.

The reason string

reason is the last argument of the money functions. It does not change the amount. It is passed along with the change so that the framework, or a logging script, can record why the money moved.

lua
Player.Functions.AddMoney('cash', 250, 'taxi-job-payout')
xPlayer.addAccountMoney('bank', 250, 'taxi-job-payout')

Use a short, consistent text that names the script and the action. When a player's balance looks wrong, a search for taxi-job-payout in the logs finds the line in seconds. If you also send logs to Discord, see Discord webhook logs. For the balance side of the economy, see balancing a FiveM economy.

Rules for safe money code

  • Change money on the server only. Never accept an amount sent by the client.
  • Check the balance before you remove, and use the return value on QBCore.
  • Pass a reason every time.
  • Pick one money source per account, so cash is not stored twice, once as a number and once as an item.

Checklist

Symptom Fix
Which ESX accounts exist money, bank, black_money
Which QBCore types exist cash, bank, crypto
Balance goes negative on ESX Check getAccount(name).money before removeAccountMoney
QBCore remove fails RemoveMoney returned false; the player has not enough
No black money on QBCore Use an item, or add a custom type to the config
Cash is an item ox_inventory: AddItem(source, 'money', amount)
Logs have no context Pass a reason string on every add and remove

Quick answers

What are the money types in ESX?

ESX has accounts named money (cash), bank and black_money. You change them with xPlayer.addAccountMoney, removeAccountMoney and read them with getAccount.

What are the money types in QBCore?

QBCore stores cash, bank and crypto in PlayerData.money. You change them with Player.Functions.AddMoney and RemoveMoney, passing the type as the first argument.

What is the reason argument for?

It is a short text that QBCore and recent ESX versions attach to the money change, so your logs show why it happened. Always pass a clear one, such as 'burger-shop'.

Scripts that skip this problem

Pawn Shop AppA player-to-player pawn market inside lb-phone.View script →Drug Dealer AppStreet sales as an lb-phone app: zones, NPC buyers, levels and police alerts.View script →Shop CreatorBuild a shop in under a minute — owners, employees, vaults and robberies included.View script →

Keep reading