Skip to main content
Server Client Optional module. Requires characters. Balances belong to the loaded character. Every change writes a ledger row in the same transaction. Accounts are defined in config/accounts.lua:
config/accounts.lua

Server

GetBalance / GetAll

nil when no character is loaded.

Add / Remove / Set

integer
required
Positive.
string
Stored in the ledger.
integer?
The new balance.
UgErrorCode?
not_loaded without a character, insufficient_funds unless the account allows negative balances, no_permission when a hook cancelled.
Set records the difference in the ledger. Add and Remove run the Accounts:BeforeAdd and Accounts:BeforeRemove hooks.

Transfer

Moves money to another character, online or offline, in one transaction. Both ledgers get a row. balance is the sender’s. Runs Accounts:BeforeTransfer.

GetLedger

integer
default:"25"
1 to 100.
UgLedgerEntry[]
Newest first.

Client

The local player’s balances, pushed by the server on every change.

Example

Listen to ug-core:Accounts:Changed with (source, account, balance, delta, reason) to update a HUD.