Zerio Duty
This is a Duty system made for ESX, this is pretty much a library with all the functions and such.
Making it very easy to link this to any UI or such.
The upside to this duty system is that in other duty systems it changes the actual job name which messes up other scripts, example: when off duty your job name is “offduty”, when on duty your job name is “police”.
This is not how this script works , this script does not change your job name, it simply uses player metadata, which is way smarter.
Links
Github Page
Pull Requests
Github Issues
Contribution
If you want to contribute to this project, then please do. We are open to any help at all, simply open a PR (Pull Request) on the Github Repository, or open an Issue on the Github Repository.
Exports
Server
- getDuty(identifier)
Gets the current duty status of the player, returns a boolean (true / false).
If the player doesnt exist / isnt online, then false will be returned. - setDuty(identifier, newValue)
Updates the duty status for the inputted player. Doesn’t return anything.
- getPlayersOnDuty(jobName)
Returns a table with all players on duty for a specific job. This is based on ESX.GetExtendedPlayers, therefore the players returned are actual player objects / ESX players.
- getPlayersOffDuty(jobName)
Returns a table with all players that are off duty for a specific job. This is based on ESX.GetExtendedPlayers, therefore the players returned are actual player objects / ESX players.
Client
- getDuty()
Gets the duty status of the local player / client, returns a boolean (true / false)
Events
Server
-
zerio-duty:server:dutyChange
Gets triggered when a players duty value is changed. It passes through the source of the player and also the new duty value.
-
zerio-duty:server:toggleDuty
Toggles the duty for the player that triggered this event. (Has to be triggered from the client)
Works great to be triggered from a “duty marker” / duty change function in a job script.
Client
- zerio-duty:client:dutyChange
This gets triggered when the local player / clients duty value gets changed. Passes through the new duty value.
Examples
EXAMPLE FOR ESX PAYCHECK EXISTS ON GITHUB
Server:
(Command displaying your duty status)
RegisterCommand("duty", function(source)
local Player = ESX.GetPlayerFromId(source)
if Player then
local onduty = exports["zerio-duty"]:getDuty(Player.identifier)
local str = "You are on duty"
if onduty == false then
str = "You are not on duty"
end
TriggerClientEvent("chat:addMessage", Player.source, {
color = {255, 255, 255},
multiline = true,
args = {"Zerio-Duty", str}
})
end
end)
(Command toggling your duty status)
RegisterCommand("changeduty", function(source)
local Player = ESX.GetPlayerFromId(source)
if Player then
local duty = exports["zerio-duty"]:getDuty(Player.identifier)
exports["zerio-duty"]:setDuty(Player.identifier, not duty)
end
end)
Client:
(Command displaying your duty status)
RegisterCommand("duty", function()
local onduty = exports["zerio-duty"]:getDuty()
local str = "You are on duty"
if onduty == false then
str = "You are not on duty"
end
TriggerEvent("chat:addMessage", {
color = {255, 255, 255},
multiline = true,
args = {"Zerio-Duty", str}
})
end)
Code is accessible | Yes |
Subscription-based | No |
Lines (approximately) | ~100 |
Requirements | ESX |
Support | Partial |
Previous Scripts:
Fivem Resource CLI
Zerio Bobcat Security Heist
Zerio Proximity Prompts
Zerio Progress Bars
Zerio Crafting
Zerio Bossmenu
Zerio Radio
Zerio Cardealer
Zerio Jobcenter
Zerio Garage
Zerio Characters