Server exports
Bank
Server exports that write a line into a character's bank history and read the character's account number and extra accounts.
These exports belong to the Bank app (apps/bank/server/accounts.lua). Any resource may call them.
They need the extra account tables from sql/install.sql (fx_pocketbook_bank_accounts, _bank_members, _bank_entries, _bank_requests). While those are missing, both exports answer false / nil and the server console says so at start.
The balance of the character's main account belongs to your banking script (vorp_banking, rsg-banking or the internal bank). See Bank adapters.
#BankAddTransaction
Writes a row into a character's bank history: a salary, rent, a fine. It moves no money. Change the balance in your own script first, then call this so the player sees why.
lua---@param characterId string 'vorp:<charidentifier>' or 'rsg:<citizenid>'
---@param cents integer above 0 = money in, below 0 = money out; not 0
---@param title string up to 60 characters
---@param counterparty? string who paid or was paid, up to 120 characters
---@param channel? string how, up to 60 characters
---@return boolean ok
exports['fx-pocketbook']:BankAddTransaction(characterId, cents, title, counterparty, channel)
luaexports['fx-pocketbook']:BankAddTransaction('vorp:12', 4500, 'Weekly wage', 'Valentine Sheriff', 'Payroll')
- Returns
falsewhen the tables are missing,characterIdis malformed or longer than 96 characters,centsis not a whole number, is0or is beyond 1e12, or a text is empty (title only) or too long. - The row is written to the character's main account history. The calling resource's name is stored with it.
- If the owner has the Bank page open, it reloads.
#GetBankData
Returns a character's account number and the extra accounts (savings and shared) the character owns or is a member of.
lua---@param characterId string 'vorp:<charidentifier>' or 'rsg:<citizenid>'
---@return table|nil data
exports['fx-pocketbook']:GetBankData(characterId)
lualocal data = exports['fx-pocketbook']:GetBankData('rsg:ABC12345')
if data then
for _, account in ipairs(data.accounts) do
print(account.no, account.name, account.balance / 100)
end
end
lua{
no = '1042', -- account number of the main account; nil if the character never opened the Bank app
accounts = {
{ id = 7, kind = 'savings', name = 'Savings', no = '0007', balance = 125000, role = 'owner' },
{ id = 9, kind = 'shared', name = 'Ranch', no = '0009', balance = 30000, role = 'member' },
},
}
| Field | What it is |
|---|---|
no |
Four-digit account number of the main account |
accounts[].id |
Account id |
accounts[].kind |
'savings' or 'shared' |
accounts[].name |
Account name |
accounts[].no |
Four-digit account number |
accounts[].balance |
Balance in cents |
accounts[].role |
'owner' or 'member' |
- Returns
nilwhen the tables are missing orcharacterIdis not a string of up to 96 characters. - Closed accounts are left out. At most 30 accounts are returned.
- The main account's balance is not included.