🪝 Hooks
Overview
Hooks let you run custom validation logic before or after banking actions. Use them to enforce custom policies (e.g. max balance per character), blacklist checks, or external integration across deposits, withdrawals, transfers, society money, loans, cards, and ATM flows.
RegisterHook
If you are writing code inside tgg-banking (for example in server/custom/*.lua), use the built-in function:
If you are writing code from an external resource, use export:
registerHook (lowercase) is also available as an alias.
Both registration methods are supported. Use the variant that matches where your script lives.
Supported events
Money actions (deposit, withdraw, transfer)
beforeDepositafterDepositbeforeWithdrawafterWithdrawbeforeTransferafterTransfer
Society money exports
beforeAddSocietyMoneyafterAddSocietyMoneybeforeRemoveSocietyMoneyafterRemoveSocietyMoney
Loan lifecycle
beforeLoanApplyafterLoanApplybeforeLoanPaymentafterLoanPaymentbeforeLoanPayoffafterLoanPayoffbeforeLoanApplyPaymentafterLoanApplyPayment
Card lifecycle
beforeCardCreateafterCardCreatebeforeCardFreezeafterCardFreezebeforeCardUnfreezeafterCardUnfreezebeforeCardTerminateafterCardTerminatebeforeCardUpdateLimitsafterCardUpdateLimits
ATM
beforeAtmAuthorizeafterAtmAuthorizebeforeAtmPinChangeafterAtmPinChange
Blocking behavior (before* hooks only)
return false-> blocks action with default message.return { success = false, message = 'Your custom message' }-> blocks action with custom message.- any other return value -> allows action.
Where to use this code
Hook code runs on the server only. Add it in one of these ways:
Put your hook script in tgg-banking/server/custom/ (e.g. server/custom/limits.lua). It loads automatically with the resource. Use the native RegisterHook function.
Create your own FiveM resource (e.g. my-banking-rules) with a server script. Add ensure tgg-banking before it in server.cfg, add tgg-banking to dependencies in your fxmanifest.lua, and use exports['tgg-banking']:RegisterHook(...).
Your callback is written as a normal Lua function in your script; the runtime handles cross-resource function references automatically.
Register hooks once when the server or resource starts (top level of your server script, not inside an event handler).
Examples
Generic outline
The examples below use the external resource form. Replace with RegisterHook when using server/custom/*.lua.
beforeDeposit
Payload: amount, reason, iban, cardNumber, accountType, accountOwnerId, playerIdentifier, newAccountBalance
Block deposits that would exceed a character's max bank balance:
afterDeposit
Same payload as beforeDeposit plus result.
Log successful deposits:
beforeWithdraw
Payload: amount, reason, iban, cardNumber, accountType, accountOwnerId, playerIdentifier
Block withdrawals above a limit or from blacklisted accounts:
afterWithdraw
Same payload as beforeWithdraw plus result.
Log successful withdrawals:
beforeTransfer
Payload: amount, reason, senderIban, targetIban, senderOwnerId, targetOwnerId, senderAccountType, targetAccountType, playerIdentifier, newTargetBalance
Block transfers that would exceed limits or to/from restricted accounts:
afterTransfer
Same payload as beforeTransfer plus result.
Log successful transfers:
beforeAddSocietyMoney / beforeRemoveSocietyMoney
Payload: society, iban, amount, currentBalance, newBalance, source, initiator (export calls use source = 0)
Block society deposits above a threshold:
beforeLoanApply / afterLoanApply
Payload: playerIdentifier, amount, duration, interestRate, paymentAmount, totalAmount, paymentFrequency, source. After hook adds loanId, loanStatus; result: { success, loanId, amount, paymentAmount, nextPaymentDate }
Log new loans:
beforeCardCreate / afterCardCreate
Payload: accountIban, playerIdentifier, displayName, color, source. After adds cardId, cardNumber. PIN and CVV never in payloads.
Block card creation for certain account types or players:
beforeAtmAuthorize / beforeAtmPinChange
Payload: cardNumber, accountIban, playerIdentifier, source. Raw PIN and new PIN never in payloads.
Block ATM access for specific cards (e.g. flagged accounts):