Studios
Treasuryhouse-3.jpg

Examples

SoonTreasuryQbox
PAGE 04 OF 06  ·  CONFIGURATION → EXAMPLES → TROUBLESHOOTINGdocs.glitchstudios.dev
Browse docs

Start from the neutral config#

On a server that is not the city this resource was built for, copy these blocks from config.generic.example.lua over the matching ones in config.lua:

Config.Accounts = {
    national = { account = 'gov_national', label = 'National Treasury' },
    state    = { account = 'gov_state',    label = 'State Treasury' },
}
Config.Gov = { federal = 'national', state = 'state' }
Config.Integrations = { dealer = false, rentals = false, businessTablet = false }
Config.TaxedResources = {}
Config.Grant.enabled = false

Then add your own job resources to Config.TaxedResources and your own scripts to Config.AllowedCallers.

Let your own script book a fee#

Add the resource name to the export's list in config.lua:

Config.AllowedCallers.Collect = { 'qbx_police', 'my-licence-office' }

Then call it from the server side of that resource:

-- amount, kind, citizenid, note
exports['glitch-treasury']:Collect(250, 'licence_boating', citizenid, 'Boating licence')

The kind decides which government receives it, through Config.FallbackRoutes or the glitch-gov routes. A kind that starts with fine_ also sends Config.FineShare to the police society account.

Book money your script already removed#

When a script removes money from a player and gives it to nobody, report it after its own removal succeeded:

if exports.qbx_core:RemoveMoney(source, 'bank', 400, 'Car wash') then
    exports['glitch-treasury']:Sink(source, 400, 'service_carwash', 'Car wash')
end

Charge stamp duty on a purchase#

local duty = exports['glitch-treasury']:StampDuty(citizenid, price, 'vehicle purchase')
if duty == 0 then
    -- the rate is zero or the buyer's bank could not cover it; nothing was booked
end

Report a food order#

A food business reports a paid customer order with a server event:

-- job, customer citizenid or 'npc', cashier citizenid or 'kiosk', price, test, order number
TriggerEvent('glitch-treasury:server:foodOrder', 'burgershot', customerCid, cashierCid, 42, false, orderNumber)

The job must be listed in Config.Grant.businesses.

Check the books#

Type treasury in the server console for the balances and the last seven days by kind. From another resource:

local rates = exports['glitch-treasury']:GetRates()
print(rates.income, rates.gst, rates.stamp)
print(exports['glitch-treasury']:GetBalance('nsw'))