Exports

Server-Side Exports

updateStats

What it does Increments a particular stat (e.g. arrests, ticketsIssued) for a player’s job, and optionally logs the event.

Parameters

  1. src (number) — the player’s server source ID

  2. jobName (string) — key of the job to update (e.g. "police")

  3. statName (string) — which stat to bump ("arrests", "ticketsIssued", etc.)

  4. amount (number) — how much to add

  5. doLog (boolean) — if true, the update will be logged (if logging is enabled)

Example

-- From server-side code, give player 10 more arrests in “police”
local src = 42
exports['sd-multijob']:updateStats(src, "police", "arrests", 10, true)

addSocietyDeposit

What it does Moves money from a boss’s personal cash or bank into the shared society account for that job.

Parameters

  1. source (number) — the boss’s server source ID

  2. jobName (string) — the society job key (e.g. "mechanic")

  3. amount (number) — how much to deposit (must be > 0)

  4. moneyType (string) — "cash" or "bank"

Returns

  • (number) new society balance on success

  • false on error (e.g. insufficient funds, invalid job)

Example

-- Boss deposits $500 from their bank into the police society
local src = 7
local newBalance = exports['sd-multijob']:addSocietyDeposit(src, "police", 500, "bank")
if newBalance then
    print(("Police society balance is now $%d"):format(newBalance))
else
    print("Deposit failed.")
end

withdrawSocietyFunds

What it does Removes money from the shared society account and gives it to the boss’s cash or bank.

Parameters

  1. source (number) — the boss’s server source ID

  2. jobName (string) — the society job key (e.g. "ambulance")

  3. amount (number) — how much to withdraw (must be > 0)

  4. moneyType (string) — "cash" or "bank"

Returns

  • (number) new society balance on success

  • false on error (e.g. not a boss, insufficient society funds)

Example

-- Boss withdraws $200 cash from the ambulance society
local src = 13
local newBalance = exports['sd-multijob']:withdrawSocietyFunds(src, "ambulance", 200, "cash")
if newBalance then
    print(("Ambulance society balance is now $%d"):format(newBalance))
else
    print("Withdrawal failed.")
end

getSocietyBalance

What it does Returns the current balance of the boss’s society account, and (if applicable) the full transaction history.

Parameters

  1. source (number) — any player source; must be a boss of at least one job

Returns

  • (number) current society balance

  • (table | nil) array of transaction records, each { date, who, name, action, amount }, or nil if using external banking

Example

-- Fetch police society balance and history
local src = 5
local balance, history = exports['sd-multijob']:getSocietyBalance(src)
if balance then
    print(("Police society has $%d"):format(balance))
    if history then
        for _, tx in ipairs(history) do
            print(("%s — %s %s $%d"):format(tx.date, tx.name, tx.action, tx.amount))
        end
    end
else
    print("You’re not a boss or could not fetch balance.")
end

addJob

What it does Adds or updates a job entry for the given player’s identifier, setting their grade and marking if they’re a boss (based on configured boss grades). Logs the event if job‐selection logging is enabled.

Parameters

  • src (number) — the player’s server source ID

  • jobName (string) — key of the job to add or update (e.g. "police")

  • grade (number) — the grade level to assign

Example

-- From server-side code, add job "police" at grade 2 for player with source 42
local src = 42
exports['sd-multijob']:addJob(src, "police", 2)

removeJob

What it does Removes the specified job from the given player’s saved jobs table (so they no longer have access to it). Does not automatically change their current active in-game job state; for that, use the corresponding player-focused callback or helper. Logs the event if job-removal logging is enabled.

Parameters

  • src (number) — the player’s server source ID

  • jobName (string) — key of the job to remove (e.g. "ambulance")

Example

-- From server-side code, remove the "ambulance" job for player with source 13
local src = 13
exports['sd-multijob']:removeJob(src, "ambulance")

logTransaction

What it does Appends an entry to the society transaction log for the specified job, recording date/time, the player’s identifier and name, the action type, and the amount moved.

Parameters

  • src (number) — the player’s server source ID

  • action (string) — type of transaction ("deposit", "withdrawal", "bonus", etc.)

  • amount (number) — amount of money moved

  • jobName (string) — key of the job whose society log to record (e.g. "police")

Example

-- From server-side code, log a $100 deposit into the police society by player 15
local src = 15
exports['sd-multijob']:logTransaction(src, "deposit", 100, "police")

Last updated