Yecoyz.
Docs/yecoyz_duty

Exports

Client and server exports of Yecoyz Duty for other resources.

Get yecoyz_duty

Other resources can read and change the duty state, read the salary multiplier and get the shift history through exports. Call a client export with exports['yecoyz_duty']:name(...), and a server export with the same syntax on the server.

Client exports

Export Arguments Returns Description
GetOwnHistory None List of shifts The local player's shift history. See shift format.
SaveOwnDutyHistory None true or false Asks the server to save the history. Shifts are saved when duty stops, so this is kept for compatibility.
SetDuty status (boolean) Nothing Goes on or off duty. The result isn't returned here, so check GetDutyState on the server or listen for duty changes in your own script.
lua
-- client
local shifts = exports['yecoyz_duty']:GetOwnHistory()
print(('You have %d shifts'):format(#shifts))

Server exports

Export Arguments Returns Description
SetDuty source, status (boolean) true if the player is on duty afterwards Goes on or off duty. Going off duty saves the running shift first.
GetDutyState source true or false Whether the player is on duty.
GetSalaryMultiplier source Number The player's current salary multiplier for their job.
GetOffDutyPayInfo None { offDutyPay, multiplier } The off-duty pay settings from Config.OffDutySettings.
lua
-- server: pay a salary with the duty multiplier
local multiplier = exports['yecoyz_duty']:GetSalaryMultiplier(source)
local amount = math.floor(baseSalary * multiplier)

if exports['yecoyz_duty']:GetDutyState(source) then
    -- pay the on-duty amount
else
    local pay = exports['yecoyz_duty']:GetOffDutyPayInfo()
    if pay.offDutyPay then
        -- pay pay.multiplier of the salary
    end
end
Tip

Check that yecoyz_duty is started before you call its exports, for example with GetResourceState('yecoyz_duty') == 'started'.