Docs

kyoJobCreator

Exports (API)

The API version is 1. Within a major version only additive changes are made; check GetApiVersion() if your integration depends on it.

  • Mutating exports run the same validation as the panel. An export cannot create a job the panel would have refused.
  • They run as the console, and the audit log records which resource called them.
  • Returned tables are copies, never the live data.

Results

Exports that change something return a Result:

-- success
{ ok = true, data = ... }

-- failure
{ ok = false, error = { code = 'ERR_NOT_FOUND', field = 'name', detail = nil } }
Error codeMeaning
ERR_INVALIDA parameter is missing or wrong (field says which)
ERR_NOT_FOUNDThe job, location or player does not exist
ERR_CONFLICTAlready exists, or would clash
ERR_FORBIDDENNot allowed
ERR_READ_ONLYThe job is linked; its definition belongs to the framework
ERR_LIMIT_REACHEDA limit in config/server.lua was reached
ERR_INSUFFICIENT_FUNDSNot enough money in the account
ERR_UNSUPPORTEDThe framework or an adapter cannot do it
ERR_DATABASEThe database refused the change
ERR_NOT_LOADED, ERR_BUSY, ERR_RATE_LIMIT, ERR_TOO_FAR, ERR_NOT_CONFIGURED, ERR_INVENTORY_FULLSee the error name
local res = exports.kyoJobCreator:AddSocietyMoney('mechanic', 5000, 'Paid by insurance')
if not res.ok then
    print(res.error.code, res.error.field)
end

Server exports

Version

ExportReturns
GetApiVersion()number

Jobs (read)

ExportReturns
GetJobs()Every job
GetJob(name)The job, or nil
JobExists(name)boolean
GetJobGrades(name)The job’s ranks ({} if it doesn’t exist)
GetJobOwnership(name)'managed', 'linked', 'adopted' or nil

Jobs (change)

ExportDescription
CreateJob(spec)Create a job. spec has the same shape the panel sends
UpdateJob(name, patch)Change some fields. Fields left out keep their value. Accepted: label, name, type, whitelisted, defaultDuty, offDutyPay, enabled
DeleteJob(name, options)Delete a job. With employees you must pass options.reassignTo (job name for them) or options.force = true
DuplicateJob(name, newName, options)Copy a job. options.withLocations copies its locations too
ExportJobPreset(name)Export the job as a preset document
ImportJobPreset(document, options)Import a preset. options.name renames it

Locations

ExportDescription
GetLocations(filter)Every location. filter may have job, kind, enabled
GetLocation(id)One location, or nil
CreateLocation(spec)Create a location. Use spec.job (job name) or spec.jobId
UpdateLocation(id, patch)Change some fields; the rest are kept
DeleteLocation(id)Delete a location
exports.kyoJobCreator:CreateLocation({
    job = 'mechanic',
    kind = 'stash',
    label = 'Parts locker',
    coords = vector3(-347.3, -133.4, 39.0),
    radius = 1.5,
    minGrade = 0,
})

Employees

ExportDescription
GetPlayerJobs(source)Every job the player may hold (multijob roster)
HasJob(source, name, minGrade)true if the player currently has that job, optionally at or above minGrade
HasJobPermission(source, permission)true if the player’s rank has a permission, e.g. 'boss.hire'
IsOnDuty(source)true if the player is on duty
SetPlayerJob(source, name, grade)Make one of the player’s jobs the active one
HirePlayer(source, name, grade, actor)Hire a player
FirePlayer(identifier, name, actor)Dismiss a player by identifier

Company account

ExportDescription
GetSocietyBalance(name)Balance of the job’s account (0 if it doesn’t exist)
AddSocietyMoney(name, amount, reason)Pay money in. reason is required
RemoveSocietyMoney(name, amount, reason)Take money out. reason is required

Framework and import

ExportDescription
GetIntegrationReport()What was resolved at boot for every adapter
ListFrameworkJobs()Jobs the framework has
GetImportReport()The Import screen’s comparison
LinkJob(name, actor)Link a framework job
AdoptJob(name, actor)Take over a job’s definition
UnlinkJob(name, actor)Unlink a job

Client exports

ExportReturns
GetApiVersion()number
GetPlayerJob()The player’s current job
GetVisibleLocations(filter)Locations this player can see
GetLocation(id)One location, or nil
IsNearLocation(id)true if the player is within the location’s radius
GetInteractionProvider()The interaction provider in use (a target resource or markers)
if exports.kyoJobCreator:IsNearLocation(12) then
    -- ...
end