API Reference

Server exports for oxide-landscapingjob — IsOnShift, GetSetting, SetSetting, GetInfo, GetShift, GetProgression and SetUpdateHandler, with integration examples for stopping players from working two jobs at once.

Reference for developers integrating another resource with oxide-landscapingjob. 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.

Server Exports

All exports are called on the server.

IsOnShift

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

local onShift = exports['oxide-landscapingjob']: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-landscapingjob']: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-landscapingjob']: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).

Yards are read from shared/config/locations.lua, not the database, so SetSetting('Yards', ...) returns false. Build yards with the in-game builder instead — see the Yard Building Guide.

See How Settings Work for how the database-backed settings relate to the config files.

GetInfo

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

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

Returns: table — with these fields:

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

GetShift

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

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

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

Returns: table|false — false when the player is not on a shift; otherwise a table with these fields:

FieldTypeDescription
locationstringThe office the shift started at
rolestringsolo, leader (leads a crew) or partner (in someone else's crew)
stagestringworking while yards are left, returning once every assigned yard is done (back to the office to clock out)
taskstring or nilThe yard being mowed, or the next one; nil otherwise
done, totalnumberYards done and yards assigned this shift
jobsnumberYards 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-landscapingjob']:GetProgression(source)

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

Returns: table|false — false when the player has no character; otherwise a table with these fields:

FieldDescription
level, titleThe player's current level and its title
countYards in total
streakDays in a row
prevAt, nextAtThe yard counts where this level starts and where the next one begins (nextAt is nil at the top level)
nextTitleThe title of the next level
timedOutWhether the player is suspended after complaints
timeoutRemainingSeconds left on the suspension

SetUpdateHandler

Lets another resource, such as a phone app, show this job's shift updates itself. The updates are the messages the job sends to the player's phone when usePhone is on.

While a handler is set and its resource is running, each update goes to the handler first. When the handler returns true, the job sends nothing else; when it returns anything else or fails, the job sends the update as usual. There is one handler at a time: setting one replaces the last.

exports['oxide-landscapingjob']:SetUpdateHandler(function(source, update)
    -- update.title: the sender, for example "Landscaping - The Mighty Bush"
    -- update.message: the message
    -- update.summary: { jobs, net } on the pay summary, sent when a shift ends on a clock-out,
    -- a deleted location or a restart (never on a disconnect, a logout or going down)
    return true -- shown; the job sends nothing else
end)

Parameters: handler (function or nil) — called as handler(source, update). Passing 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 (that handler 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-landscapingjob') == 'started'
        and exports['oxide-landscapingjob']:IsOnShift(src) then
        -- tell the player to finish their landscaping shift first
        return
    end
    -- start your job
end)

Check every gig job at once

The same IsOnShift(source) export exists on oxide-postaljob, oxide-pizzajob, oxide-landscapingjob, oxide-roadsideassistancejob, oxide-animalcontroljob and oxide-newspaperjob. 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

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

Next Steps