AI Core

ai-banking for developers

Job society money exports of ai-banking (also under qb-banking and Renewed-Banking names), and the lib calls to use instead in new code.

ai-banking keeps no money of its own. In new code, move job and gang money with ai-core's shared money exports (GetSharedMoney, AddSharedMoney, RemoveSharedMoney) or the lib's money.transfer, and open the bank screen with the lib's banking.open(source). These work with every banking script. The exports below exist so QBCore scripts written for qb-banking or Renewed-Banking keep working.

banking.open

Opens the active banking script's screen for a player.

Side: Server · Waits: no

Signature
banking.open(source: number): boolean
Lua
local ok = aiLib.banking.open(source)

Returns

true when the screen opened. false when the banking script cannot be opened from outside, or none runs.

Not every banking script can be opened from another resource. Check what banking.open answers before telling the player anything.

money.transfer

Moves money between two accounts in one database transaction, writing both ledger rows. Used by ai-banking for every deposit, withdrawal and transfer.

Side: Server · Waits: no

Signature
money.transfer(from: MoneyRef, to: MoneyRef, amount: number, reason?: string, fee?: number): boolean
Lua
local ok = exports['ai-core']:TransferMoney(from, to, amount, reason, fee)

Parameters

Prop

Type

MoneyRef

Prop

Type

Returns

true when the money moved. false when an account is missing, both are the same, or from cannot pay.

Example

A boss pays a bonus from the job account into a member's bank:

import { money, notify } from "@aicore-fivem/lib/server";

function payBonus(boss: number, member: number, amount: number): void {
  const ok = money.transfer(
    { owner: "job", id: "police", account: "bank" },
    { source: member, account: "bank" },
    amount,
    "bonus",
  );
  notify(boss, ok ? "Bonus paid" : "The job account cannot pay", ok ? "success" : "error");
}

Server exports

All three act on ai-core's bank account of a job (the account name is the job name). They also answer as exports['qb-banking']:<same name>, and as Renewed-Banking's getAccountMoney, addAccountMoney and removeAccountMoney. They are not typed in @aicore-fivem/shared: in TypeScript use callExport("ai-banking", name, ...args). Each export also answers under its lower-case twin (getAccountBalance).

GetAccountBalance

A job's society balance.

Side: Server · Waits: no

Signature
GetAccountBalance(job: string): number
Lua
local balance = exports['ai-banking']:GetAccountBalance('police')
-- the same: exports['qb-banking']:GetAccountBalance('police')
-- the same: exports['Renewed-Banking']:getAccountMoney('police')

Parameters

Prop

Type

Returns

The balance in $. 0 when the job has no account or job is not a text.

AddMoney

Adds money to a job's society account. Every boss with the bank screen open sees the new balance.

Side: Server · Waits: no

Signature
AddMoney(job: string, amount: number, reason?: string): boolean
Lua
local ok = exports['ai-banking']:AddMoney('police', 500, 'fine')
-- the same: exports['Renewed-Banking']:addAccountMoney('police', 500, 'fine')

Parameters

Prop

Type

Returns

true when the money was added. false when job is not a text, amount is not above 0, or ai-core refused (no such job account).

RemoveMoney

Takes money from a job's society account.

Side: Server · Waits: no

Signature
RemoveMoney(job: string, amount: number, reason?: string): boolean
Lua
local ok = exports['ai-banking']:RemoveMoney('mechanic', 1200, 'parts')

Parameters

Prop

Type

Returns

true when the money was taken. false when the account cannot pay, does not exist, or the arguments are wrong.

Example

import { callExport } from "@aicore-fivem/lib/server";

// A mechanic script buys parts from the job account.
function buyParts(cost: number): boolean {
  return callExport("ai-banking", "RemoveMoney", "mechanic", cost, "parts") === true;
}

These exports only reach job accounts. For a gang account use ai-core's AddSharedMoney('gang', name, 'bank', amount, reason) and friends. Money changed through ai-core's exports directly is the same money, but open bank screens only update at once for changes made through ai-banking.

Private callbacks

The bank screen's calls (resource/common/bank.ts): open, history pages, deposit, withdraw, transfer and close. The server checks the branch or ATM position on every call. They may change between versions: do not call them from other resources.

On this page