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
src
(number) — the player’s server source IDjobName
(string) — key of the job to update (e.g."police"
)statName
(string) — which stat to bump ("arrests"
,"ticketsIssued"
, etc.)amount
(number) — how much to adddoLog
(boolean) — iftrue
, 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
source
(number) — the boss’s server source IDjobName
(string) — the society job key (e.g."mechanic"
)amount
(number) — how much to deposit (must be > 0)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
source
(number) — the boss’s server source IDjobName
(string) — the society job key (e.g."ambulance"
)amount
(number) — how much to withdraw (must be > 0)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
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 }
, ornil
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")
getSavedJobs
What it does Returns a Lua table mapping every saved job name to its grade for a given player.
Parameters
srcOrIdent
(number | string) — either the player’s server source ID or their identifier string.
Returns
(table) — a map where keys are job names and values are grade numbers. Returns an empty table if the identifier is invalid or has no saved jobs.
Example
-- From server-side code, fetch and print the saved jobs for player source 42
local src = 42
local jobs = exports['sd-multijob']:getSavedJobs(src)
for jobName, grade in pairs(jobs) do
print(("[sd-multijob] %s: grade %d"):format(jobName, grade))
end
-- Or using an identifier directly:
local identifier = "steam:110000112345678"
local jobsByIdent = exports['sd-multijob']:getSavedJobs(identifier)
print("Jobs for", identifier, ":", json.encode(jobsByIdent))
for job, grade in pairs(exports['sd-multijob']:getSavedJobs(src)) do print(job, grade) end
Last updated