FiveM Docs
Addons

esx_banking

esx_banking adds banks, ATMs, PIN codes, transfers and transaction history to ESX Legacy. Config defaults, the logTransaction export and security model.

esx_banking is the official bank and ATM resource for ESX Legacy. Players walk up to a bank counter or an ATM, press E and use a web UI to deposit, withdraw, transfer money to other players and set an ATM PIN. Every transaction is validated on the server and written to a history table.

Overview

Resourceesx_banking (version 1.0.1)
SideClient, server and NUI
Dependenciesesx_lib, es_extended, oxmysql
SQL filebanking.sql (table banking, adds users.pincode)
InteractionE near a bank or ATM, shown with esx_textui
Server exportlogTransaction

Installation

Import the SQL

Run banking.sql. It creates the banking history table and adds a nullable pincode column to users. If you skip it, the resource runs the same migration on start, but it requires both tables to use InnoDB. On failure the console prints Schema migration failed; banking disabled.

Ensure the resource

server.cfg
ensure es_extended
ensure esx_banking

Configuration

KeyDefaultDescription
DebugfalsePrints debug messages on the server
DrawMarker10Distance at which bank markers are drawn (only with ShowMarker)
LocaleGetConvar('esx:locale', 'en')Language
EnablePedstrueSpawns the networked bank clerk peds from Peds
ShowMarkerfalseDraws a marker at each bank position
InteractionDistance1.5Max distance to a bank Position, client and server
AtmInteractionDistance2.0Max distance to an ATM, checked on the server
ClientAtmFallbackfalseTrusts ATM coords sent by the client, but only if they match an AtmLocations entry
ClientAtmFallbackDistance1.75Distance used for that fallback check
RequireAtmPintrueATM sessions need the 4-digit PIN before money can move
SessionDuration90Seconds a bank/ATM session stays valid, refreshed by each action
TransactionCooldown1250Rate limit in ms between transactions
PinAttemptCooldown1500Rate limit in ms between PIN attempts
MaxTransactionAmount100000000Highest amount per transaction
HistoryLimit20Rows shown in the history (max 100)
HistoryDays30Only rows from the last N days are shown
LogRetentionDays60Rows older than this are deleted on start. 0 keeps everything
LogValueMaxLength80Max length of label and type in a log row
AtmModelsprop_fleeca_atm, prop_atm_01, prop_atm_02, prop_atm_03ATM prop hashes
AtmLocations70 vector3 positionsKnown ATM positions used for server-side distance checks
Banks8 entriesBank counters, see below
Peds8 entriesClerk peds, see below

Each Banks entry:

{
    Position = vector4(149.91, -1040.74, 29.374, 160),
    Blip = { Enabled = true, Color = 69, Label = 'Bank', Sprite = 108, Scale = 0.7 }
}

Each Peds entry has Position (vector4), Model (hash, default `U_M_M_BankMan`) and Scenario (default 'WORLD_HUMAN_CLIPBOARD').

Custom ATMs

The server only opens an ATM session when the player stands near an AtmLocations entry or a networked ATM object. If you add ATMs with a map, add their positions to AtmLocations, otherwise the UI will refuse to open.

Security model

The client only sends requests. The server:

  • starts a session in esx_banking:getPlayerData only when the player is near a bank or ATM,
  • re-checks the distance on every action and expires sessions after SessionDuration,
  • allows transfers and PIN changes only in bank sessions,
  • requires the PIN for ATM sessions when RequireAtmPin is on,
  • rate limits opening (750 ms), transactions and PIN attempts, and locks one transaction per player at a time.

Server export

logTransaction

Adds a row to a player's bank history. It does not move money. Use it when another resource charges the bank account and you want it to show up in the banking UI.

exports.esx_banking:logTransaction(playerId, label, key, amount)
NameTypeDescription
playerIdnumberServer id of an online player
labelstringText shown in the history, e.g. CAR PURCHASE
keystringTransaction type, e.g. WITHDRAW or DEPOSIT. Required, stored upper-case
amountnumberPositive amount up to MaxTransactionAmount
server/main.lua
local xPlayer = ESX.GetPlayerFromId(source)

if xPlayer.getAccount('bank').money >= price then
    xPlayer.removeAccountMoney('bank', price, 'Vehicle purchase')
    exports.esx_banking:logTransaction(source, 'CAR PURCHASE', 'WITHDRAW', price)
end

Events and callbacks

NameTypeDescription
esx_banking:doingTypeNet event (client to server)Deposit, withdraw, transfer or PIN change. Payload { action = 'deposit', amount = 500 }, { action = 'transfer', target = id, amount = n }, { action = 'pincode', pin = '1234' }
esx_banking:getPlayerDataCallbackOpens a session. Argument { accessType = 'bank' or 'atm', atm = ... }
esx_banking:checkPincodeCallbackUnlocks an ATM session with a 4-digit PIN
esx_banking:closebankingClient eventCloses the banking UI. Useful when you cuff or kill a player
esx_banking:updateMoneyInUIClient eventServer pushes fresh balances to the UI
esx_banking:pedHandlerClient eventServer sends the network ids of the clerk peds

Client-triggerable

esx_banking:doingType and the callbacks can be called by any client. They are safe only because of the session and distance checks above. Do not loosen ClientAtmFallback or the distances without a reason.

Close the UI from another resource:

server/main.lua
TriggerClientEvent('esx_banking:closebanking', targetId)

Common issues

  • E prompt shows but the UI does not open: the server distance check failed. Usually a custom ATM not listed in AtmLocations.
  • "Payments disabled" or "banking disabled" in the console: users or banking is not InnoDB, or the identifier column is not VARCHAR.
  • Old scripts call TriggerServerEvent('esx_banking:logTransaction', ...): that event was removed. Move the call to the server export.

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