Duty System

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:

Update Duty Status to unit
TriggerServerEvent("l2s-dispatch:server:SetDutyStatus", BOOL)

Update server/v_editable.lua Code for Custom Duty System:

function ToggleDuty(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 status
end

function GetDuty(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 set
    return true

end

Last updated