Browse docs
Internal Job Banking
Overview
sky_base includes an internal job banking backend for shared society accounts. It stores one row per job in the sky_job_accounts table and keeps the current amount in the balance column.
This is useful when a banking script does not support a job account the way a Sky script expects it, or when you want a simple, stable backup for job balances.
Configuration
Use the internal backend as the main society banking system:
Config.banking = "sky"
Or keep your existing banking resource and only use the internal table when the selected adapter fails:
Config.banking = "auto"
Config.useSkyBankingFallback = true
The fallback only takes over for failed shared-account calls. If your external banking resource returns a valid balance or accepts the transaction, sky_base keeps using that resource.
Database Table
sky_base creates the table automatically on start when Config.banking = "sky" or Config.useSkyBankingFallback = true.
CREATE TABLE IF NOT EXISTS `sky_job_accounts` (
`job` VARCHAR(64) NOT NULL,
`balance` BIGINT NOT NULL DEFAULT 0,
`created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
`updated_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`job`)
) DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
Job names are stored without the society_ prefix. For example, both police and society_police use the police row.
Server Exports
local balance = exports["sky_base"]:getJobBalance("police")
exports["sky_base"]:setJobBalance("police", 25000)
exports["sky_base"]:addJobBalance("police", 5000)
local removed = exports["sky_base"]:removeJobBalance("police", 1500)
if not removed then
print("Not enough money in the job account")
end
removeJobBalance never allows the balance to go below zero. It returns false when the account has insufficient funds.