Exports
Here you will find all the useful exports for this asset, please read each step and example carefully to better understand how it works, we do not recommend using these if you are not an experienced developer.
REMEMBER ABOUT CLIENT SIDE AND SERVER SIDE IN CHOOSING EXPORT!
GetDutyData
To fetch player duty data you need to use following export.
exports['piotreq_jobcore']:GetDutyData()
Example of Usage
local data = exports['piotreq_jobcore']:GetDutyData()
print(json.encode(data, {indent=true}))
--[[
{
"status": 1,
}
]]
DutyPlayersTrigger
You can use this export to trigger some client event for players with specific job.
eventName
string
data
any
(args for event)job
string
online?
boolean
(if true then only trigger for players which are on duty else all players in table
exports['piotreq_jobcore']:DutyPlayersTrigger(eventName, data, job, online)
Example of Usage
local eventName = 'restaurants:refreshOrders'
local data = {'Order'}
local job = 'burgershot'
local online = true
exports['piotreq_jobcore']:DutyPlayersTrigger(eventName, data, job, online)
On Duty Update
With this event handler you are able to follow player duty updates.
AddEventHandler('piotreq_jobcore:UpdateDuty', function(data)
print(json.encode(data))
end)
ResetDutyTimer
You can use this export to reset duty time for specific player.
identifier
string
exports['piotreq_jobcore']:ResetDutyTimer(identifier)
Example of Usage
exports['piotreq_jobcore']:ResetDutyTimer('char:12345678')
ResetDutyTimers
With this export you can reset duty time for all players in specific job.
job
string
type
string
("all", "online", "offline")
exports['piotreq_jobcore']:ResetDutyTimers({
job = job,
type = type
})
Example of Usage
exports['piotreq_jobcore']:ResetDutyTimers({
job = 'police',
type = 'all'
})
ToggleDuty
You can use following trigger to toggle duty status
duty
number
(0 = off duty, 1 = on duty, 2 = break)
TriggerServerEvent('piotreq_jobcore:SwitchDuty', {duty = 1})
FormatDutyTime
Use following export to receive formatted duty time
time
number
exports['piotreq_jobcore']:FormatDutyTime(time)
Example of Usage
local time = 100
local formattedTime = exports['piotreq_jobcore']:FormatDutyTime(time)
print(formattedTime)
SavePlayerDutyTime
You can use this export to save player duty time manually.
identifier
string
time
number
exports['piotreq_jobcore']:SavePlayerDutyTime(identifier, time)
Example of Usage
local identifier = 'char:123456789' -- replace it with player identifier
local time = 100 -- replace it with player duty time
exports['piotreq_jobcore']:SavePlayerDutyTime(identifier, time)
isPlayerOnDuty
You can check if specific player is on duty with this export.
identifier
string
exports['piotreq_jobcore']:isPlayerOnDuty(identifier)
Example of Usage
local identifier = 'char:123456789' -- replace this with player identifier
local result = exports['piotreq_jobcore']:isPlayerOnDuty(identifier)
print(result)
GetJobDutyPlayers
With this export you are able to get all online players with specific job
job
string
exports['piotreq_jobcore']:GetJobDutyPlayers(job)
Example of Usage
local job = 'police'
local players = exports['piotreq_jobcore']:GetJobDutyPlayers(job)
print(json.encode(players, {indent=true}))
GetAllDutyPlayers
This export will get all online players with job from config
exports['piotreq_jobcore']:GetAllDutyPlayers()
Example of Usage
local players = iotreq_jobcore']:GetAllDutyPlayers()
print(json.encode(players, {indent=true}))
SetPlayerDutyData
identifier
string
data
table
playerId
string
jobName
string
status
number
time
number
startTime?
number
exports['piotreq_jobcore']:SetPlayerDutyData(identifier, {
identifier = identifier,
player = playerId,
job = jobName,
status = status,
time = time,
startTime = startTime
})
Example of Usage
local identifier = 'char1:1234578' -- replace this with player identifier
local playerId = 1 -- replace it with player id
local jobName = 'police' -- replace it with player job
local status = 1 -- (0 = off duty, 1 = on duty, 2 = on break)
local time = 100 -- replace it with player duty time
local startTime = os.time() -- should be os.time every time
exports['piotreq_jobcore']:SetPlayerDutyData(identifier, {
identifier = identifier,
player = playerId,
job = jobName,
status = status,
time = time,
startTime = startTime
})
GetJobActivePlayers
This export will return on duty players count from specific job / jobs.
job
string / table
exports['piotreq_jobcore']:GetJobActivePlayers(job)
Example of Usage
local job = 'police'
-- local job = {'police', 'ambulance', 'sheriff'} -- it can be table
local count = exports['piotreq_jobcore']:GetJobActivePlayers(job)
print(count)
Last updated