ESXserver
xPlayer.removeAccountMoney
ESX server documentation with a FiveM Lua example.
Summary
Removes money from a named ESX account such as bank or black_money. Check that the account exists and has enough money before removing it.
Returns
void
Parameters
accountNamestringThe ESX account name, such as bank or black_money.amountnumberThe positive amount to remove.reasonstringOptional reason recorded by supported ESX logging integrations.Example
local xPlayer = ESX.GetPlayerFromId(src)
local account = xPlayer and xPlayer.getAccount('bank')
if account and account.money >= 100 then
xPlayer.removeAccountMoney('bank', 100, 'shop-purchase')
-- payment succeeded, give the item
endCommon pitfalls
- Use removeMoney for the main cash account; use removeAccountMoney for named accounts such as bank.
- Validate the player, account, amount and purchase server-side before removing money or granting a reward.
- Check the balance first so the account cannot be charged below the amount your flow expects.
Related functions
Related guides
FiveM scripts done right
Optimized, dual-framework scripts for QBCore and ESX from Viper Development — escrow protected, delivered instantly to your Cfx portal.
Browse Scripts →