In QBCore, the duty system is built into the framework by default. To ensure that players with specific jobs are required to be on duty before using dispatch, you can use the following functions:
QBCore Version comes fully equipped with a default duty system.
Update server/v_editable.lua Code for Custom Duty System:
functionToggleDuty(src,boolean) -- To Link your duty system with dispatch script-- local Player = QBCore.Functions.GetPlayer(src) -- Get the player object by their source ID-- Player.Functions.SetJobDuty(boolean) -- Set the player's job duty status based on the boolean (true/false)TriggerClientEvent(Shared.Settings.SetDuty, src, boolean) -- Notify the client with the updated duty statusendfunctionGetDuty(src) -- To get initial value for duty status-- local Player = QBCore.Functions.GetPlayer(src) -- Retrieve the player object--return Player.PlayerData.job.onduty or true -- Return the duty status of the player, defaults to true if not setreturntrueend