API
Events and callbacks for Yecoyz Duty, for scripts that talk to it directly.
Get yecoyz_dutyMost scripts should use the exports. Use the events and callbacks below when you need to talk to Duty directly.
Client events
| Event | Arguments | Description |
|---|---|---|
yecoyz_duty:notify |
localeKey, notifyType |
Shows a translated notification. localeKey is a key from locales/*.json. |
Server callbacks
Call these with Core.Callback from a resource that loads @yecoyz_core/import.lua. See the yecoyz_core callbacks.
| Callback | Arguments | Returns | Description |
|---|---|---|---|
yecoyz_duty:setDuty |
source, status |
{ onDuty, dutyStarted } |
Goes on or off duty. dutyStarted is the start time of the current shift, or nil. |
yecoyz_duty:startDuty |
source |
true or false |
Starts a shift. Fails when the job isn't in Config.Jobs. |
yecoyz_duty:stopDuty |
source |
true or false |
Ends the current shift and saves it. |
yecoyz_duty:getStandaloneDuty |
source |
true or false |
Whether the player is on duty. |
yecoyz_duty:getActiveDutyTime |
source |
Start time, or nil |
When the current shift started. |
yecoyz_duty:getHistory |
source |
List of shifts | The player's own shifts. See shift format. |
yecoyz_duty:getEmployeHistory |
source, identifier |
List of shifts | Shifts of one employee. Bosses only, and only the shifts worked in the boss's job. |
yecoyz_duty:isBoss |
source |
true or false |
Whether the player can manage employees. |
yecoyz_duty:getActiveWorkers |
source |
List of players | Employees of the player's job who are on duty right now. |
yecoyz_duty:getAllEmployees |
source |
List of employees | Everyone in the player's job. |
yecoyz_duty:getFullName |
source |
String | The player's full name. Returns Unknown Unknown when it can't be read. |
yecoyz_duty:updateHistory |
None | true |
Kept for compatibility. Shifts are saved when duty stops. |
lua
-- client
local history = Core.Callback.Await('yecoyz_duty:getHistory')Shift format
Each entry in a shift list is a table with these fields:
| Field | Type | Description |
|---|---|---|
job |
String | The job name the shift was worked in. |
jobLabel |
String | The job's label. |
startTime |
Number | Unix time when the shift started. |
endTime |
Number | Unix time when the shift ended. |
startTimeFormatted |
String | Start time as YYYY-MM-DD HH:MM:SS. |
endTimeFormatted |
String | End time as YYYY-MM-DD HH:MM:SS. |
duration |
Number | Length of the shift in seconds. |