Bank API
Server exports for charging and paying players, money holds and bank accounts. Read Charging a Player for the common path and Bank Accounts for roles and rules.
Charging and paying
Takes a payment in cash or from the bank and returns a receipt RefundPlayer can undo. See Charging a Player.
| Param | Type | Description |
|---|---|---|
| source | number | Player server ID |
| amount | number | A whole number, 0 or more (0 takes nothing and still returns a receipt) |
| opts.method | string? | 'cash', 'bank' or 'auto' (default: cash if they carry enough, else the bank) |
| opts.accountId | number? | Bank: which account (default their default one); their withdraw permission is checked |
| opts.currency | string? | Cash: the item that counts as money (default 'cash'). A refund returns the very items taken, with what they carry (a paid gun keeps its serial) |
| opts.reason | string? | On the statement and the activity log (default 'Payment') |
receipt|false, string|nil: receipt { id, amount, method, accountId, currency, refunded }; the error is a sentence the player can readGives back a payment ChargePlayer took, the way it came, with no permission check (see Refunding). Only the resource that charged may refund, up to what's left, within 30 minutes.
| Param | Type | Description |
|---|---|---|
| receipt | table|number | The receipt, or its id |
| amount | number? | How much (default: everything not yet refunded) |
bool, string|nil: false when it couldn't be delivered (also printed as CRITICAL)Pays a player: a wage, a reward, a sale. Cash that doesn't fit their pockets lands at their feet, and every payment is on the activity log with your resource's name.
| Param | Type | Description |
|---|---|---|
| who | number|table | A server id, or { charId = n } for a character who may be offline |
| amount | number | A whole number, 0 or more (0 pays nothing) |
| opts.method | string? | 'cash', 'bank' or 'auto' (default: cash while they're online, else their bank) |
| opts.accountId | number? | Bank: which account (default their default one) |
| opts.currency | string? | Cash: the item paid (default 'cash') |
| opts.reason | string? | On the statement and the activity log |
{ method, amount, currency?, placement?, accountId? } (placement: 'inventory' or 'ground'), or false, reason: as ChargePlayer returns its receiptMoney holds#
For a metered service (fuel, a taxi fare), hold the most it could cost, report what's used as it runs, and settle: the rest goes back. whip_fuel's pumps work this way. Nothing is lost if your resource or the server stops first: the refund owed is noted on the character with the charge and paid at their next login. The payer leaving, or your resource or whip_core stopping, settles it for what was used. Cash change goes to their pockets (the bank if it doesn't fit). Only your resource can spend or settle its holds.
Takes amount from the player now, cash or bank. opts = { method = 'cash' | 'bank', reason, vehicle? }: vehicle (a vehicleId) keeps that car's row unwritten until the settle, so fuel not yet paid for is never saved.
false, why (not enough money, no bank account)local holdId, why = exports.whip_core:HoldMoney(source, 100, { method = 'cash', reason = 'Car wash' })
if not holdId then return false, why end
-- each cycle: SpendMoneyHold(holdId, usedSoFar); at the end: SettleMoneyHold(holdId)
Reports how much of the hold is used so far (0 up to what was held): what a settle keeps if your resource or the server stops first.
true, or false, why when the hold is gone (the payer left) or isn't yours: stop the service thenEnds the hold: spent (default: what SpendMoneyHold last said) is kept, the rest goes back, the note is cleared and a held vehicle's row is written, all together.
{ spent, refunded, paidNow } (paidNow false: the change is paid at the next login), or false, why when already settled or not yoursOne of your holds as it is now. Ask before giving more of the service.
{ source, amount, spent, method }, or nil: it's over, or not yoursReading accounts
A balance from memory: only the first read of an account waits for the database, and every bank write keeps it true. A HUD, phone app or ATM prompt can ask as often as it shows it.
| Param | Type | Description |
|---|---|---|
| who | number|table | A person for their main account, or { accountId = n } |
integer, or false, why: no such person or account, no bank account, or it's closedAn account, by its ID or its number.
| Param | Type | Description |
|---|---|---|
| ref | number|table | A bank account ID, or { number = 'WB-XXXXXX' } |
table|nil: { accountId, accountNumber, label, type, ownerCharId, jobId, balance, isDefault, frozen, createdAt }, as every account read; times are epoch secondsA person's default account: a database read every call. To show a balance, use GetBalance.
| Param | Type | Description |
|---|---|---|
| who | number|table | Server id, or { charId = n } |
table|nilIs the player standing at a cash machine? GTA's own machines and Config.AtmExtraPositions, measured across the ground from each machine's base. For a resource that wants the standing-at-a-machine rule; WHIP's own ATMs find machines by model and don't ask this.
| Param | Type | Description |
|---|---|---|
| source | number | Server id |
| range | number? | Metres, 0.5 to 10. Default AtmActiveRange + 1 |
true, at (the machine's base) or false, whyThe cash machine nearest a place, from the same list as IsNearAtm, within 3 m of its height.
| Param | Type | Description |
|---|---|---|
| coords | vector3|table | The place |
at, distance (the machine's base, and the distance across the ground), or nilEvery account a character can use, each with their role on it. To offer accounts to pay from, keep withdraw, manager and owner: the others are refused at the till.
| Param | Type | Description |
|---|---|---|
| charId | number | Character ID |
table[]: accounts with a role fieldA job's accounts. None yet means the job has no owner.
| Param | Type | Description |
|---|---|---|
| job | number|string | jobId or key ('police') |
table: accounts; {}, 'No such job' for a job that doesn't existAn account's history, newest first.
| Param | Type | Description |
|---|---|---|
| accountId | number | Bank account ID |
| limit | number? | Rows to return (default 50, at most 500) |
| offset | number? | Rows to skip (default 0) |
table: rows of { txId, fromAccountId, toAccountId, type, amount, fromBalance, toBalance, actorCharId, message, createdAt }; type is 'deposit', 'withdraw', 'transfer' or 'payment'. A row is money out when fromAccountId is this accountWho has access to an account, and their roles.
| Param | Type | Description |
|---|---|---|
| accountId | number | Bank account ID |
table: array of { charId, role, grantedBy }A player's moves
Whether a person may act at role level on an account, by the bank's own rule: ask before offering accounts or menu options.
| Param | Type | Description |
|---|---|---|
| accountId | number | Bank account ID |
| who | number|table | A person |
| role | string | 'view', 'deposit', 'withdraw', 'manager' or 'owner'; each includes those before it |
bool, string|nil: false, 'Needs withdraw access to this account', 'Account not found'A player pays into an account. For the system paying in, use BankSystemDeposit.
| Param | Type | Description |
|---|---|---|
| accountId | number | Bank account ID |
| amount | number | A whole number, 1 or more |
| actor | number|table | The person depositing (required): deposit or higher |
| opts.reason | string? | Shown on the statement |
bool, string|nil; fires whip_core:bank:balanceChangedChargePlayer(source, n, { method = 'cash' }), and refund that receipt if the deposit is refused. Otherwise a deposit makes money from nothing.A player takes money out of an account. To charge for something, use ChargePlayer instead.
| Param | Type | Description |
|---|---|---|
| accountId | number | Bank account ID |
| amount | number | A whole number, 1 or more |
| actor | number|table | The person withdrawing (required): withdraw or higher |
| opts.reason | string? | Shown on the statement |
bool, string|nilPayPlayer(source, amount, { method = 'cash' }) once this returns true. Otherwise the money leaves the account and they get nothing.A player moves money between accounts; withdraw on the source is checked. For payroll, use BankSystemTransfer.
| Param | Type | Description |
|---|---|---|
| fromId | number | Source account |
| toId | number | Destination account |
| amount | number | A whole number, 1 or more |
| actor | number|table | The person transferring (required) |
| opts.reason | string? | Shown on the statement |
bool, string|nil: 'Insufficient funds', 'No withdraw permission on source account'...System moves
Your resource decides: no permission check, and the activity log records your resource's name.
Pays into an account: a wage, a sale's takings, a reward.
| Param | Type | Description |
|---|---|---|
| accountId | number | Target bank account ID |
| amount | number | A whole number, 1 or more |
| opts | table? | { reason, actorCharId }: the reason (on the statement), and who caused it |
bool, string|nilTakes money out of an account: a fine, a fee, a bill.
| Param | Type | Description |
|---|---|---|
| accountId | number | Bank account ID |
| amount | number | A whole number, 1 or more |
| opts | table? | { reason, actorCharId } |
bool, string|nil: 'Insufficient funds', 'Account is frozen'Moves money between two accounts, such as payroll from a job's account (GetJobBankAccounts) to an employee's default one. Otherwise refused as a transfer would be.
| Param | Type | Description |
|---|---|---|
| fromId | number | Source account |
| toId | number | Destination account |
| amount | number | A whole number, 1 or more |
| opts | table? | { reason, actorCharId } |
bool, string|nilOpening, sharing and closing
Opens an account at $0. A character may own at most Config.MaxExtraAccounts savings and shared accounts (default 5); personal and job accounts don't count.
| Param | Type | Description |
|---|---|---|
| owner | number|table | The person who owns it |
| label | string? | Display name, 1-50 characters (default Config.DefaultAccountLabel) |
| opts.type | string? | 'personal' (default), 'savings', 'business' or 'shared' |
| opts.job | number|string? | A business account's job, by jobId or key; a missing job returns false, 'No such job' |
table|false, string|nil: the account, or false and why ('A character may have at most 5 savings and shared accounts'...)Gives a character access to an account. The granter can only give roles below their own, to someone below them, and can't change the owner. Refused for another character of the granter's or owner's player while Config.BlockOwnCharacterTransfers is on.
| Param | Type | Description |
|---|---|---|
| accountId | number | Bank account ID |
| who | number|table | The person getting access |
| role | string | 'view', 'deposit', 'withdraw' or 'manager' |
| grantedBy | number|table | The person granting: their role is checked |
bool, string|nilWhether GrantBankAccess would allow it, writing nothing: the phone's Bank app asks before sending an invite, then grants on acceptance.
| Param | Type | Description |
|---|---|---|
| accountId | number | Bank account ID |
| who | number|table | The person who would get it |
| role | string | The role they would get |
| grantedBy | number|table | The person who would grant it |
bool, string|nilMarks an account closed, and everyone's access goes with it. The balance must be zero, and a default account can't be closed.
| Param | Type | Description |
|---|---|---|
| accountId | number | Bank account ID |
| who | number|table? | The person closing it, checked: they must own it, and it must be savings or shared. Leave it out when your code or an admin decides |
bool, string|nil: 'Account must have zero balance', 'Cannot close default account', 'Only the owner can close this account'...Freezes or unfreezes an account, say for a court order. Every move in or out is then refused with 'Account is frozen', also on the ATM; money and access stay. No permission check; the activity log records your resource.
| Param | Type | Description |
|---|---|---|
| accountId | number | Bank account ID |
| frozen | boolean | true to freeze, false to unfreeze |
true, or false, why ('Account not found'...)Vehicle values
What your resource charges for vehicles. Banks values an owned car at this price, averaged across resources. Declare it in Whip.register; again replaces your list, and it goes when your resource stops.
| Param | Type | Description |
|---|---|---|
| prices | table | { [model] = price } in dollars, more than 0: { adder = 1000000 } |
true, or false, why