Skip to main content
Server Client Proxied to ug-core. 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
Read the account list with UgCore.Config.Get('accounts', 'accounts'), on the server or the client.

Server

GetBalance / GetAll

nil when no character is loaded.

Add / Remove / Set

string
required
An account from config/accounts.lua. Unknown accounts raise.
integer
required
1 to 1,000,000,000,000.
string
Up to 128 characters. Stored in the ledger.
integer?
The new balance.
Set records the difference in the ledger. It accepts negative balances only for accounts with allowNegative, and raises otherwise.

Transfer

Moves money to another character, online or offline, in one transaction. Both ledgers get a row that points to the other character. balance is the sender’s.

GetLedger

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

Client

The local player’s balances, sent by the server to that player only, on load and on every change. Other players’ balances never reach a client.

Errors

Unknown accounts, out-of-range amounts and long reasons raise.

Events

On the server, it fires for every change of an online character, including both sides of a transfer. On the client, it fires for the local player’s own balances only: on load, on every change, and with balance = nil when the character unloads. Use it to update a HUD:
client.lua

Hooks

Hooks allow or cancel. Changes to the payload are ignored.

Example