NX CreativeNX CreativeDocs
Scriptsnx_realbanking

Exports

Public exports registered by nx_realbanking, split into server and client.

All server exports live under exports.nx_realbanking:<Name>(). Client exports use the same pattern inside a client-side script.

Server

exports.nx_realbanking:CreateInvoiceserver

Insert a new invoice into the database and return its reference id.

Parameters

  • datatableInvoice payload. Required: senderIdentifier, receiverIdentifier, amount, label. Optional: senderName, receiverName, type ("society" | "freelance" | "personal", default "personal"), senderJob, senderJobLabel, govAccount, societyAccount.

Returns

boolean success, string|nil refIdOrError
local ok, refId = exports.nx_realbanking:CreateInvoice({
    senderIdentifier = 'char1:abc',
    senderName = 'John Smith',
    receiverIdentifier = 'char1:xyz',
    receiverName = 'Jane Doe',
    type = 'personal',
    amount = 250.00,
    label = 'Ride share'
})
exports.nx_realbanking:GetInvoiceserver

Look up an invoice by numeric id or reference id.

Parameters

  • invoiceRefstring|numberNumeric invoice id or reference id (e.g. "INV-ABC123").

Returns

table|nil
local invoice = exports.nx_realbanking:GetInvoice('INV-ABC123')
exports.nx_realbanking:GetInvoiceByRefserver

Fetch a single invoice row by its reference id.

Parameters

  • refIdstringReference id returned from CreateInvoice.

Returns

table|nil
local invoice = exports.nx_realbanking:GetInvoiceByRef('INV-ABC123')
if invoice then
    print(invoice.amount, invoice.status)
end
exports.nx_realbanking:GetPlayerInvoicesserver

List invoices received by a given player, newest first.

Parameters

  • identifierstringPlayer identifier (framework-specific: ESX identifier or QB citizenid).
  • status?stringFilter: 'pending' | 'paid' | 'cancelled' | 'overdue'. Omit for all.

Returns

table[]
local pending = exports.nx_realbanking:GetPlayerInvoices('char1:abc', 'pending')
print(('%d pending invoice(s)'):format(#pending))
exports.nx_realbanking:GetSentInvoicesserver

List invoices a player has sent.

Parameters

  • identifierstringPlayer identifier of the sender.
  • status?stringFilter: 'pending' | 'paid' | 'cancelled' | 'overdue'. Omit for all.

Returns

table[]
local sent = exports.nx_realbanking:GetSentInvoices('char1:abc', 'pending')
exports.nx_realbanking:GetSocietyInvoicesserver

List invoices issued under a given society or job.

Parameters

  • jobstringJob name (matches Config.Societies key).
  • status?stringFilter: 'pending' | 'paid' | 'cancelled' | 'overdue'. Omit for all.

Returns

table[]
local policeInvoices = exports.nx_realbanking:GetSocietyInvoices('police', 'pending')
exports.nx_realbanking:PayInvoiceserver

Pay an invoice on behalf of the given source. Funds are pulled from the player's default account and distributed to society / commission / VAT destinations.

Parameters

  • refIdstringReference id of the invoice to pay.
  • sourcenumberServer id of the paying player.

Returns

boolean success, string|nil error
local ok, err = exports.nx_realbanking:PayInvoice('INV-ABC123', source)
if not ok then
    print('Payment failed:', err)
end
exports.nx_realbanking:CancelInvoiceserver

Cancel a pending invoice. Bypasses the player-level cancel checks. Intended for admin or system flows.

Parameters

  • refIdstringReference id of the invoice to cancel.
  • reason?stringOptional reason recorded in the audit log.

Returns

boolean success, string|nil error
local ok, err = exports.nx_realbanking:CancelInvoice('INV-ABC123', 'duplicate')
exports.nx_realbanking:GetPendingInvoiceCountserver

Count a player's pending invoices in either direction.

Parameters

  • identifierstringPlayer identifier.
  • direction?'received' | 'sent'Direction to count. Defaults to 'received'.

Returns

number
local count = exports.nx_realbanking:GetPendingInvoiceCount('char1:abc', 'received')
exports.nx_realbanking:ChargeCreditCardserver

Charge an amount against a credit card. Supply one of cardId, cardNumber, or citizenId to resolve the card.

Parameters

  • payloadtableFields: amount (number, required), cardId | cardNumber | citizenId (one required), merchant (string, optional), transactionType (string, optional).

Returns

table { success: boolean, error?: string, ... }
local result = exports.nx_realbanking:ChargeCreditCard({
    citizenId = 'char1:abc',
    amount = 1200,
    merchant = 'Ammu-Nation',
    transactionType = 'purchase'
})

if not result.success then
    print('Charge failed:', result.error)
end
exports.nx_realbanking:ApplyCreditCardserver

Run the credit-application flow for a player. Assesses score, checks tier eligibility, and either issues a card or returns a rejection reason.

Parameters

  • sourcenumberServer id of the applying player.
  • requestedTier?stringOne of 'standard', 'gold', 'black'. Omit to auto-assign the highest eligible tier from Config.Credit.tierPriority.

Returns

table { success: boolean, error?: string, card?: table, tier?: string, score?: number, ... }
local result = exports.nx_realbanking:ApplyCreditCard(source, 'gold')
if result.success then
    print('Issued', result.tier, 'card #', result.card.number)
else
    print('Rejected:', result.error)
end

The Online* exports below mirror the bank UI actions with the ATM distance check removed, so another server resource such as a laptop or phone banking app can run them for a player who is nowhere near an ATM. Every other guard still runs: rate limiting, account access, ownership, status, and balance validation. These are server-only, so a client cannot reach them directly. Pass the player's own source, and call them only once your resource has authenticated that player's session.

Each returns a table shaped { success = boolean, error = string|nil } plus whatever fields the underlying action produces.

exports.nx_realbanking:OnlineTransferserver

Move money between two accounts without requiring ATM proximity.

Parameters

  • sourcenumberServer id of the player making the transfer.
  • datatableFields: fromAccountId (or fromAccount), toAccountId (or toAccount), amount (number). Optional: description (string).

Returns

table { success: boolean, error?: string, ... }
local result = exports.nx_realbanking:OnlineTransfer(source, {
    fromAccountId = 'ACC-1001',
    toAccountId = 'ACC-2002',
    amount = 500.00,
    description = 'Rent'
})
exports.nx_realbanking:OnlineCreateAccountserver

Open a new account for the calling player without requiring ATM proximity.

Parameters

  • sourcenumberServer id of the player opening the account.
  • datatableFields: accountType ('personal' | 'business' | 'savings'), pin (4-digit numeric string). Optional: accountName (string).

Returns

table { success: boolean, error?: string, ... }
local result = exports.nx_realbanking:OnlineCreateAccount(source, {
    accountType = 'savings',
    accountName = 'Rainy day',
    pin = '4821'
})
exports.nx_realbanking:OnlineCloseAccountserver

Close an account the calling player owns, without requiring ATM proximity.

Parameters

  • sourcenumberServer id of the requesting player.
  • datatableFields: accountId (string).

Returns

table { success: boolean, error?: string, ... }
local result = exports.nx_realbanking:OnlineCloseAccount(source, {
    accountId = 'ACC-1001'
})
exports.nx_realbanking:OnlineAddMemberserver

Add a member to a shared account without requiring ATM proximity.

Parameters

  • sourcenumberServer id of the account owner or manager.
  • datatableFields: accountId (string), and citizenId (string) or targetSource (number) to identify the new member. Optional: role (string), permissions (table), limits (table).

Returns

table { success: boolean, error?: string, ... }
local result = exports.nx_realbanking:OnlineAddMember(source, {
    accountId = 'ACC-1001',
    citizenId = 'char1:xyz',
    role = 'teller'
})
exports.nx_realbanking:OnlineTransferOwnershipserver

Hand ownership of an account to another citizen, without requiring ATM proximity.

Parameters

  • sourcenumberServer id of the current owner.
  • datatableFields: accountId (string), citizenId (string) of the new owner.

Returns

table { success: boolean, error?: string, ... }
local result = exports.nx_realbanking:OnlineTransferOwnership(source, {
    accountId = 'ACC-1001',
    citizenId = 'char1:xyz'
})
exports.nx_realbanking:OnlineApplyCreditCardserver

Rate-limited credit application without ATM proximity. Use this instead of ApplyCreditCard when the caller is a remote banking surface.

Parameters

  • sourcenumberServer id of the applying player.
  • datatableOptional. Field: requestedTier ('standard' | 'gold' | 'black'). Omit to auto-assign the highest eligible tier.

Returns

table { success: boolean, error?: string, card?: table, tier?: string, score?: number, ... }
local result = exports.nx_realbanking:OnlineApplyCreditCard(source, {
    requestedTier = 'gold'
})

The logging exports below let your own resource write into the same Discord channels the bank uses, so a shop purchase or a heist payout lands in the same audit trail as a withdrawal.

exports.nx_realbanking:LogBankEventserver

Record an event in the bank's Discord log. Routing, formatting and delivery follow whatever the server owner configured for that category.

Parameters

  • entrytableFields: event (string, snake_case key), category ('transactions' | 'security' | 'invoices' | 'credit' | 'accounts' | 'admin'), severity ('info' | 'success' | 'warning' | 'critical'). Identify the player with source, or citizenId when they are offline. Optional: playerName, headline, summary, digest, fields (array of { name, value, inline }), footer.

Returns

table { success: boolean, error?: string }
local result = exports.nx_realbanking:LogBankEvent({
    event     = 'shop_purchase',
    category  = 'transactions',
    severity  = 'info',
    source    = source,
    headline  = 'Ammunation purchase',
    summary   = 'Bought a weapon licence',
    fields    = { { name = 'Merchant', value = 'Ammunation', inline = true } }
})

if not result.success then
    print('Not logged:', result.error) -- e.g. CATEGORY_DISABLED
end

Text you pass is escaped before it reaches Discord, so a player name containing formatting or a link cannot forge content in the log.

Returns CATEGORY_DISABLED when the server owner has that category switched off or has set no webhook for it. That is a normal outcome, not an error to retry.

exports.nx_realbanking:GetLogStatusserver

Current delivery state, for an admin command or a health check.

Returns

table { queues: table[], disabled: string[] }
local status = exports.nx_realbanking:GetLogStatus()

for _, q in ipairs(status.queues) do
    print(('%s: %d waiting, %d dropped'):format(q.category, q.pending, q.dropped))
end

disabled lists webhooks that Discord rejected, usually because the URL was deleted or its token regenerated. Those are switched off until the resource restarts and are reported in the server console.

Client

exports.nx_realbanking:IsAtATMclient

Returns true while the player is within detection range of a known ATM prop.

Returns

boolean
if exports.nx_realbanking:IsAtATM() then
    -- Custom interaction prompt
end
exports.nx_realbanking:GetNearestATMclient

Returns the current ATM context, or nil if none is in range.

Returns

{ entity: number, coords: vector3, distance: number, hash: number } | nil
local atm = exports.nx_realbanking:GetNearestATM()
if atm and atm.distance < 1.5 then
    print('Standing at ATM', atm.entity)
end
exports.nx_realbanking:IsInteractingclient

Returns true while the ATM session is active (camera engaged, NUI open).

Returns

boolean
if exports.nx_realbanking:IsInteracting() then
    -- Suppress your own UI while banking
end
exports.nx_realbanking:GetSessionclient

Returns the current client-side session descriptor, or nil when idle.

Returns

table | nil
local session = exports.nx_realbanking:GetSession()
if session then
    print('Session id:', session.id)
end

On this page

NX Docs