Skip to Content
AM Scripts Docs
Exports

Exports

Client exports

openBank

Opens desktop banking for an optional bank key.

---@param bankId string|nil e.g. 'fleeca', 'maze', 'pacific'
---@return boolean opened
local opened = exports['stormix-banking']:openBank('fleeca')

openATM

Opens an ATM session for a local ATM prop. The model, position and player proximity are validated by the server. The call waits for the session to start.

---@param context table bankId, atmModel, coords and optional netId
---@param entity number local ATM entity handle
---@return boolean opened
local coords = GetEntityCoords(entity)
local opened = exports['stormix-banking']:openATM({
    bankId = 'fleeca',
    atmModel = 'prop_atm_02',
    coords = { x = coords.x, y = coords.y, z = coords.z },
    netId = NetworkGetEntityIsNetworked(entity) and NetworkGetNetworkIdFromEntity(entity) or nil,
}, entity)

isBankOpen

Returns whether the local player currently has a banking session.

---@return boolean open
local open = exports['stormix-banking']:isBankOpen()

closeBank

Closes the banking session and cleans up its focus and ATM view. It does not close an external phone app.

exports['stormix-banking']:closeBank()

**

Server exports

Invoices

Invoices are paid later through the bank or phone. Creating one does not charge the player. See the mechanic invoice example.

createInvoice

Creates an unpaid society invoice. operationId must be unique for the work order and reused on retry. A retry with the same details returns the existing invoice; changing its details fails.

---@param input table billFrom, billTo, amount, label, operationId, groupType?
---@return table result { ok, data = { id, replayed? } } or { ok = false, error }
local result = exports['stormix-banking']:createInvoice({
    billFrom = 'mechanic',        -- society/group name
    billTo = 8,                   -- online server ID or character identifier
    amount = 750,                 -- whole dollars
    label = 'Engine repair',
    operationId = 'repair:1042',  -- stable, 8?64 bytes
    -- groupType = 'job',         -- optional: job, gang, system or ox
})
if result.ok then print(result.data.id) else print(result.error.code) end

The due date uses billing.dueDays. The full namespaced operation key must fit 128 bytes. The creating resource is responsible for authorizing the society and bill.

sendInvoice

Legacy version of createInvoice; returns the invoice ID or nil instead of a result table. An omitted operation ID creates a new invoice every time, so retries can duplicate bills.

---@param input table same invoice fields as createInvoice
---@return string|nil invoiceId
local id = exports['stormix-banking']:sendInvoice({
    billFrom = 'mechanic', billTo = 8, amount = 750,
    label = 'Engine repair', operationId = 'repair:1042',
})
getInvoice

Reads an invoice created by the calling resource. The returned data includes id, number, issuerAccountId, recipientIdentifier, amountCents, label, status, dueAt, and payment details when available.

---@param invoiceId string invoice UUID
---@return table result
local result = exports['stormix-banking']:getInvoice(invoiceId)
if result.ok then print(result.data.status, result.data.amountCents) end
cancelInvoice

Cancels an unpaid invoice created by the calling resource. A repeated cancellation returns data.replayed = true; paid invoices cannot be cancelled or refunded by this export.

---@param invoiceId string invoice UUID
---@return table result
local result = exports['stormix-banking']:cancelInvoice(invoiceId)
payInvoice

Pays an invoice after the player has authorized payment. Banking checks the recipient, account permission, amount and invoice status. The invoice is already credited to its issuer; do not credit it again.

---@param playerSource number online player's server ID
---@param invoiceId string invoice UUID
---@param payerAccountId string account UUID
---@return table result success data contains receiptId and optional replayed
local result = exports['stormix-banking']:payInvoice(playerSource, invoiceId, payerAccountId)

Accounts

Account lookups return result.data with id, iban, bankId, name, kind, ownerType, ownerId, status, primary and balanceCents. A missing account returns an error; it does not open a new personal account.

getPersonalAccount

Finds a character's active primary personal account.

---@param target number|string online server ID or character identifier
---@return table result
local result = exports['stormix-banking']:getPersonalAccount(8)
if result.ok then print(result.data.iban, result.data.balanceCents / 100) end
getAccountById
---@param accountId string account UUID
---@return table result
local result = exports['stormix-banking']:getAccountById(accountId)
getAccountByIban

Looks up the player-visible account number. Whitespace and case are ignored.

---@param iban string account number
---@return table result
local result = exports['stormix-banking']:getAccountByIban('SB31 FLEE 1234 5678')
getBusinessAccount

Finds or creates the configured society account and returns its details.

---@param name string society or group name
---@param groupType string|nil job, gang, system or ox
---@return table result
local result = exports['stormix-banking']:getBusinessAccount('mechanic', 'job')

**

Society balances

Society exports use whole dollars. The group type is job, gang, system or ox; it can be omitted when the name resolves unambiguously. Configure system societies in config/config.lua.

ensureSocietyAccount
---@param name string society or group name
---@param groupType string|nil
---@return string|nil accountId account UUID
local accountId = exports['stormix-banking']:ensureSocietyAccount('mechanic', 'job')
getSocietyMoney

Zero is a valid balance; check explicitly for false.

---@param name string society or group name
---@param groupType string|nil
---@return number|false balance whole dollars
local balance = exports['stormix-banking']:getSocietyMoney('mechanic', 'job')
if balance ~= false then print(balance) end
addSocietyMoney

Credits a society from an external source. This does not debit another account.

---@param name string society or group name
---@param dollars number positive whole dollars
---@param groupType string|nil
---@param operationId string stable, 8?64 bytes
---@return boolean success
local ok = exports['stormix-banking']:addSocietyMoney('government', 250, 'system', 'tax:1042')
removeSocietyMoney

Debits a society for an external expense. Both mutations require a stable operation ID: identical retries do not move money twice; changing the request with the same ID fails.

---@param name string society or group name
---@param dollars number positive whole dollars
---@param groupType string|nil
---@param operationId string stable, 8?64 bytes
---@return boolean success
local ok = exports['stormix-banking']:removeSocietyMoney('mechanic', 250, 'job', 'expense:1042')

See the government treasury example for integration details.


Paychecks

queuePaycheck

Queues an unpaid salary for the character to claim. Do not also pay the same salary directly into the bank. The framework must be an authorized payroll caller; external Ox providers may queue salaries when built-in payroll is off.

---@param identifier string character identifier
---@param dollars number positive whole dollars
---@param sourceName string salary label
---@param providerKey string stable salary/period key
---@return table result success has value and optional replayed; failure has error
local result = exports['stormix-banking']:queuePaycheck(
    identifier, 500, 'Police Department', 'salary:character:period-1042'
)
if not result.ok then print(result.error.code) end

Rewards

Rewards use the policy in config/server_config.lua. Report only purchases already validated and settled by your server resource. See rewards for configuration, return values and refund behavior.

addRewardPoints

Grants custom points for a server-validated activity. Reuse the same operation ID on retries.

---@param target number|string online server ID or character identifier
---@param points number positive integer
---@param label string history description
---@param operationId string stable, 8?100 bytes
---@return table result success data contains id, points, balance and optional replayed
local result = exports['stormix-banking']:addRewardPoints(8, 50, 'Delivery completed', 'delivery:1042')
if result.ok then print(result.data.balance) end
getRewardPoints
---@param target number|string online server ID or character identifier
---@return table result success data contains points
local result = exports['stormix-banking']:getRewardPoints(8)
if result.ok then print(result.data.points) end
awardMerchantPurchase

Reports a completed purchase for configured points and cashback. It does not charge the player or deliver goods.

---@param purchase table verified purchase details
---@return table result
local result = exports['stormix-banking']:awardMerchantPurchase({
    key = 'repair:1042',
    citizenid = customerIdentifier,
    accountId = paidFromAccountId,
    amountCents = 75000,
    category = 'vehicle_service',
    merchantOwnerCitizenid = shopOwnerIdentifier,
})
reverseMerchantPurchase

Reverses rewards for a completed refund. Call it from the same resource that reported the purchase.

---@param refundKey string stable refund ID, 8?128 bytes
---@param originalPurchaseKey string original purchase ID, 8?128 bytes
---@return table result
local result = exports['stormix-banking']:reverseMerchantPurchase('refund:1042', 'repair:1042')

On this page