All resources

rsg-banking – Technical Docs#

File layout#

FilePurpose
shared/config.luaAll gameplay config (banks, hours, fees, loans, lockboxes, doors, blips)
server/sv_config.luaServer-only webhook config (never sent to clients)
server/database.luaAuto table creation / missing-table check, ledger pruning. Sets BankingDBReady
server/webhooks.luaBankLog, BankLogActive, BankLogLarge, BankLogBlocked, BankLogSuspicious, BankMoney
server/server.luaCore helpers (Bank table), account/deposit/withdraw/wire/home callbacks, balance exports
server/lock.luaBranch lock state, exports, getLocks callback, expiry thread
server/loans.luaLoan callbacks, credit score, overdue penalty, auto-collection and default handling
server/lockbox.luaLockbox rent/upgrade/store/take/payRent callbacks, rent processing loop, lockbox export
server/homebank.luaHome branch, RSG-Core bank money forwarding, one-off legacy money migration
server/sendmoney.luaRecipient lookup and send-to-citizen callback
server/interest.luaDaily interest payout, bankinterestnow command
server/business.luaJob/gang accounts and withdrawal list callbacks
server/telegram.luarsg-telegram receipts, large alerts, statement callback
client/client.luaPrompts, blips, doors, closing-time handling, NUI bridge
html/*NUI (vanilla JS, custom dropdowns, draggable panel)

Request flow#

  1. Prompt → rsg-banking:client:open → callback rsg-banking:server:getData.
  2. Every NUI action → nuiAction → rsg-core callback with the current bank id first.
  3. Server Bank.guarded(src, bankId, fn) checks, in order: DB ready, per-player lock, rate limit (Config.Cooldown, notifies sv_slow_down), server-side distance (Config.ServerMaxDistance), opening hours (rsg-weather clock), player exists.
  4. The handler runs inside pcall; refreshed data is always returned so the UI re-renders.

Security model#

  • Client never sends a bank id it can choose freely: the server re-checks distance to that bank's coords.
  • Amounts: validAmount (number, finite, ≥ 0.01, ≤ MaxTransaction, rounded to cents). Lockbox qty: integer 1–100000.
  • Lockbox deposits write the DB first and take the item second (rolled back on failure); withdrawals reserve the DB row first, then give the item.
  • Paychecks forwarded from core bank money are returned if the branch credit fails; withdrawals check the cash payout and refund the vault on failure.
  • Balance changes are atomic SQL (balance >= ? guard on debit); every multi-step operation refunds on failure.
  • Lockbox items must be whitelisted in Config.Lockbox.items and exist in RSGCore.Shared.Items.
  • Send money: sender debited first, recipient credited via home branch with rollback; fee, per-transfer max and a 24 h limit are all server-side; the recipient is looked up by citizen ID only (throttled, must be at a bank).
  • Business accounts: authorisation is re-read from the player's live job/gang on every call; only the boss manages the list or opens the account; per-withdrawal limits apply.
  • Interest runs in one SQL transaction and records last_interest before paying, so a crash cannot pay twice.
  • Branch locks are server state, capped by Config.Lock.maxSeconds; lock events can only be triggered from the server (AddEventHandler).
  • Lockbox rent and defaults use the database clock; seizing and eviction clear DB rows before notifying.
  • Loan repayments race-guarded against auto-collection (owed >= ?).

Database tables#

rsg_bank_accounts, rsg_bank_transactions, rsg_bank_home, rsg_bank_meta, rsg_bank_loans, rsg_bank_lockboxes, rsg_bank_lockbox_items, rsg_bank_credit, rsg_bank_business_members. rsg_bank_lockboxes has a rent_until column; when upgrading with AutoDatabase = false import installation/update_3.1.0.sql. Created automatically when Config.AutoDatabase = true; otherwise import installation/rsg_banking.sql. rsg_bank_transactions has a created_idx (created_at) index; existing tables get it added automatically. Old ledger rows are pruned at start and every 6 hours (Config.HistoryDays).

Server callbacks#

NameArgs (after bankId)
rsg-banking:server:getData–
rsg-banking:server:openAccount–
rsg-banking:server:setHome–
rsg-banking:server:deposit / withdrawamount
rsg-banking:server:transfertargetBankId, amount
rsg-banking:server:takeLoanamount
rsg-banking:server:repayLoanamount, method (bank/cash)
rsg-banking:server:buyLockboxsize
rsg-banking:server:upgradeLockbox–
rsg-banking:server:lockboxDeposit / lockboxWithdrawitem, qty
rsg-banking:server:payRent–
rsg-banking:server:lookupRecipientcitizenId
rsg-banking:server:sendMoneycitizenId, amount
rsg-banking:server:sendStatement–
rsg-banking:server:bizOpenorgKey
rsg-banking:server:bizDeposit / bizWithdraworgKey, amount
rsg-banking:server:bizAddMember / bizRemoveMemberorgKey, citizenId
rsg-banking:server:getLocks– (no bankId)

Events#

  • rsg-banking:client:open (client, bankId) – open a branch menu (other resources may trigger it).

  • Client: closes the menu on RSGCore:Client:OnPlayerUnload, on death, when walking away, or at closing time.

  • Listens to RSGCore:Server:OnMoneyChange (forwards core bank adds to the home branch) and RSGCore:Server:PlayerLoaded (sweeps legacy money).

  • Server events: rsg-banking:server:lockBranch(bankId, seconds, reason) / unlockBranch(bankId) (server-side only), rsg-banking:server:loanDefaulted(citizenid, bankId, owed, seized), rsg-banking:server:lockboxEvicted(citizenid, bankId, items).

  • Client: rsg-banking:client:branchLock(bankId, locked) broadcasts lock state.

Exports#

See the README "Server exports" section.

Locales#

locales/*.json (en, de, el, es, fr, ja, nl, pl, pt-br, ro, ru). Prefixes: cl_ client, sv_ server notify, tx_ ledger notes, tg_ telegram text, ui_ NUI (all ui_* keys are sent to the NUI on first open).

Console#

  • bankinterestnow – pays savings interest immediately (console only).
  • bankwebhooktest – sends a test embed for every webhook event (console only).
<!-- BEGIN AUTO-REFERENCE (generated from the code; re-run the generator instead of editing by hand) -->

Technical reference#

Generated from the source of rsg-banking 3.1.0. Names, arguments and defaults below are read straight from the code.

Dependencies#

rsg-core, rsg-inventory, oxmysql

Database#

Tables: rsg_bank_accounts, rsg_bank_transactions, rsg_bank_home, rsg_bank_meta, rsg_bank_loans, rsg_bank_lockboxes, rsg_bank_credit, rsg_bank_business_members, rsg_bank_lockbox_items.

Tables are created automatically on start while Config.AutoDatabase = true (default). Nothing is ever dropped or overwritten. For a manual install set Config.AutoDatabase = false and import installation/rsg_banking.sql / installation/update_3.1.0.sql once.

-- shared/config.lua
Config.AutoDatabase = true -- false = import the SQL file yourself

Configuration#

OptionDefaultNotes
Config.AutoDatabasetruecreate tables automatically on start (false = import installation/rsg_banking.sql)
Config.OpenKey'J'RSGCore.Shared.Keybinds key
Config.ServerMaxDistance5.0max distance from the bank for any transaction (server checked)
Config.Cooldown500ms between bank requests per player (anti-spam)
Config.AllowPushToTalkWhileOpentrueWhile NUI is open, block game controls but allow push-to-talk.
Config.PushToTalkControlstable
Config.MaxTransaction100000per single deposit/withdraw/transfer
Config.HistoryLimit15transactions shown in the ledger
Config.HistoryDays30delete ledger entries older than this on start (0 = keep forever)
Config.AccountOpenFee5cash fee to open an account (0 = free)
Config.UseHourstrueOpening hours (in-game clock). Set Config.UseHours = false for 24/7 banks
Config.OpenHour7
Config.CloseHour21
Config.ClosingtableClosing time: stop players getting locked inside
Config.DefaultHomeBank'valentine'used by the migration for players with no accounts yet
Config.ForwardCoreBanktruemove money other scripts add to RSG-Core 'bank' into the home branch
Config.MigrateCoreMoneytrueone-off: move old bank/valbank/rhobank/blkbank/armbank money into branches
Config.TransferFeePercent5% fee charged on branch-to-branch wires
Config.TransferMinFee1minimum fee in $
Config.Loanstableand must be repaid (from the branch vault or cash) at the same branch.
Config.CredittableThe highest tier a player's score reaches sets their loan terms. Below the lowest tier they can't borrow.
Config.InteresttableShared (business) accounts never earn interest. If the server was offline it pays once, never for missed perio
Config.SendtableSend money to another citizen: arrives in their home branch (works while they are offline)
Config.BusinesstableBusiness accounts: one shared account per job / gang per branch. The boss opens it and decides who may withdra
Config.TelegramtableTelegrams (needs rsg-telegram). Receipts are written straight into its inbox.
Config.Locktableto shut a branch's services while it is being robbed. A lock always expires after maxSeconds.
Config.LockboxtableCapacity is total item count (e.g. 25 = 25 gold bars).
Config.BliptableBlip
Config.BankstableEach bank is its own institution: money deposited here stays here.
Config.BankDoorstablestate = 1 -> always locked (vaults, back rooms)

Exports#

Server

ExportArgumentsFile
GetHomeBranch``server/homebank.lua
AddHomeMoney``server/homebank.lua
SweepCoreBank``server/homebank.lua
GetLoanscitizenidserver/loans.lua
GetCreditScorecitizenidserver/loans.lua
HasActiveLoancitizenidserver/loans.lua
LockBranch``server/lock.lua
UnlockBranch``server/lock.lua
IsBranchLocked``server/lock.lua
GetLockboxItemscitizenid, bankIdserver/lockbox.lua
HasAccountcitizenid, bankIdserver/server.lua
GetBranchBalancecitizenid, bankIdserver/server.lua
GetTotalBalancecitizenidserver/server.lua
AddBranchMoneycitizenid, bankId, amount, noteserver/server.lua
RemoveBranchMoneycitizenid, bankId, amount, noteserver/server.lua
-- example
local result = exports['rsg-banking']:GetHomeBranch()

Events#

Server events can be fired by any client, so every handler re-validates the player, the arguments and any permission, distance or cooldown on the server. Never add a reward to a handler without those checks.

EventSideArgumentsFile
rsg-banking:client:openclientbankIdclient/client.lua
rsg-banking:client:branchLockclientbankId, lockedclient/client.lua
RSGCore:Client:OnPlayerUnloadclient``client/client.lua
-- from a server script
TriggerClientEvent('rsg-banking:client:open', source, bankId)

Commands#

CommandNotesFile
/bankinterestnowserver/interest.lua
/bankwebhooktestserver/webhooks.lua

Locales#

Language files in locales/: de, el, en, es, fr, ja, nl, pl, pt-br, ro, ru. Set the language with setr rsg:locale "en".

<!-- END AUTO-REFERENCE -->