API Reference

Server exports provided by oxide-roadsideassistancejob — IsOnShift, GetSetting, SetSetting, GetInfo, GetShift, GetProgression and SetUpdateHandler — with integration examples.

Reference for developers integrating another resource with oxide-roadsideassistancejob. Everything here is a server-side export; there are no client exports. If you just run the resource as a server owner, you don't need anything on this page.

Guard your calls

Check GetResourceState('oxide-roadsideassistancejob') == 'started' before calling an export, so your resource still works when this job isn't installed.

Server Exports

All exports are called on the server.

ExportReturnsWhat it does
IsOnShift(source)booleanWhether a player is on a roadside assistance shift right now
GetSetting(key)anyReads one database-backed setting
SetSetting(key, value)booleanChanges one setting live, and saves it
GetInfo()tableThe tow yards, whether each has room, and the base pay (read-only)
GetShift(source)table or falseA player's shift as the job holds it now (read-only)
GetProgression(source)table or falseA player's level with this job (read-only)
SetUpdateHandler(handler)booleanLets another resource, such as a phone app, show shift updates itself

IsOnShift

Tells you whether a player is currently on a roadside assistance shift. Use it to stop a player from starting another job while they're already working this one.

local onShift = exports['oxide-roadsideassistancejob']:IsOnShift(source)

Parameters:

NameTypeDescription
sourcenumberThe player's server id

Returns: boolean — true from the moment the player clocks in until the shift ends, whether they clock out, log out or disconnect. false otherwise, including for an id that isn't a player.

A player who joined someone else's shift through a crew invite counts as on shift too.

GetSetting

Reads one of the resource's database-backed settings, keyed by the setting name without the Config. prefix.

local maxSlots = exports['oxide-roadsideassistancejob']:GetSetting('MaxSlotsPerLocation')

Parameters: key (string) — the setting name.

Returns: any — the current value.

SetSetting

Changes one of the resource's settings.

local ok = exports['oxide-roadsideassistancejob']:SetSetting('uniformsEnabled', true)

Parameters: key (string), value (any) — the setting name and its new value.

Returns: boolean — true when the change was applied. The change is live: the server uses it right away, it saves to the database, and it syncs to clients. It persists across restarts.

Returns false if the resource hasn't finished loading its settings yet, or if the value can't be stored (for example, a number that isn't finite).

SetSetting does not check permissions — only the in-game /roadside settings editor is admin-gated. If your resource calls it on behalf of a player, do your own permission check first.

See How Settings Work for how database-backed settings behave.

GetInfo

The tow yards, whether each has room for another worker, and the base pay. Read-only.

local info = exports['oxide-roadsideassistancejob']:GetInfo()

Returns: table:

FieldTypeDescription
locationstable[]One entry per tow yard: name (string), coords (vector3) and open (boolean, false while it has as many workers as it takes)
basePaytablemin and max: the base pay per call before bonuses (the lowest and highest call type)
crewbooleanWhether players can work it as a crew of two

GetShift

A player's shift as the job holds it now. Read-only.

local shift = exports['oxide-roadsideassistancejob']:GetShift(source)

Parameters: source (number) — the player's server id.

Returns: table or false — false when the player is not on a shift; otherwise:

FieldTypeDescription
locationstringThe tow yard the shift started at
rolestringsolo, leader (leads a crew) or partner (in someone else's crew)
stagestringwaiting for a call, offer while a call waits to be accepted, working on an accepted call
taskstring or nilThe type of the call on offer or in progress; nil otherwise
done, totalnumberAlways 0, 0 (calls come one at a time)
jobsnumberCalls paid for this shift so far
earnednumberPay earned so far before the deductions taken at clock-out (for a crew partner, what they would be paid now)

GetProgression

A player's level with this job. Read-only: a character who has never worked the job reads as level 1, and no record is created.

local progression = exports['oxide-roadsideassistancejob']:GetProgression(source)

Parameters: source (number) — the player's server id.

Returns: table or false — false when the player has no character; otherwise:

FieldDescription
level, titleThe player's level and its title
countCalls in total
streakDays in a row
prevAt, nextAtThe call counts where this level starts and where the next one begins; nextAt is nil at the top level
nextTitleThe next level's title; nil at the top level
timedOutSuspended after complaints
timeoutRemainingSeconds left on the suspension

SetUpdateHandler

Lets another resource, such as a phone app, show this job's shift updates itself. While a handler is set and its resource runs, each update goes to it first: the messages the job sends to the phone when usePhone is on, and each incoming call (title "Incoming Call", message the call type).

When the handler returns true, the job sends nothing else; when it returns anything else or fails, the job sends the update as before. One handler at a time: setting one replaces the last.

exports['oxide-roadsideassistancejob']:SetUpdateHandler(function(source, update)
    -- update.title: the sender, for example "Roadside Assistance - Tow Yard"
    -- update.message: the message
    -- update.summary: { jobs, net } on the pay summary when the shift ends
    return true -- shown; the job sends nothing else
end)

Parameters: handler (function or nil) — handler(source, update). nil removes the handler your resource set. It is also removed when your resource stops.

Returns: boolean — true, or false when nil would remove another resource's handler (it stays).

Integration Examples

Stop a player from working two jobs at once

Check before your own job lets the player clock in:

RegisterNetEvent('my-job:server:clockIn', function()
    local src = source
    if GetResourceState('oxide-roadsideassistancejob') == 'started'
        and exports['oxide-roadsideassistancejob']:IsOnShift(src) then
        -- tell the player to finish their roadside assistance shift first
        return
    end
    -- start your job
end)

Check every gig job at once

The same IsOnShift(source) export exists on oxide-postaljob (GoPostal), oxide-pizzajob (Pizza Job), oxide-landscapingjob (Landscaping), oxide-roadsideassistancejob, oxide-animalcontroljob (Animal Control) and oxide-newspaperjob (Newspaper). Skip any you don't run:

local GIG_JOBS = {
    'oxide-postaljob',
    'oxide-pizzajob',
    'oxide-landscapingjob',
    'oxide-roadsideassistancejob',
    'oxide-animalcontroljob',
    'oxide-newspaperjob',
}

local function isOnGigShift(src)
    for _, resource in ipairs(GIG_JOBS) do
        if GetResourceState(resource) == 'started' and exports[resource]:IsOnShift(src) then
            return true
        end
    end
    return false
end

Next Steps