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.
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.
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.
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.
local job = 'police'
-- local job = {'police', 'ambulance', 'sheriff'} -- it can be table
local count = exports['piotreq_jobcore']:GetJobActivePlayers(job)
print(count)