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")
Last updated