mirror of
https://github.com/jimathy/jim_bridge.git
synced 2026-08-19 14:56:02 +01:00
Better syncing of onDuty variable
Added a check to the script start to get the current players duty (helpful if yours saves the duty through restarts) Also added core specific triggers for job/duty changes to help keep these in sync
This commit is contained in:
@@ -12,7 +12,9 @@
|
|||||||
-------------------------------------------------------------
|
-------------------------------------------------------------
|
||||||
-- Global Duty Status
|
-- Global Duty Status
|
||||||
-------------------------------------------------------------
|
-------------------------------------------------------------
|
||||||
onDuty = false
|
-- This attempts to sync up with the players framework onDuty variable
|
||||||
|
-- This stops the script getting confused when one is false and one is true
|
||||||
|
onDuty = not isServer() and getPlayer().onDuty or false
|
||||||
|
|
||||||
-------------------------------------------------------------
|
-------------------------------------------------------------
|
||||||
-- Boss Role Detection
|
-- Boss Role Detection
|
||||||
@@ -92,11 +94,14 @@ end
|
|||||||
--- toggleDuty() -- Player receives a notification of their new duty status.
|
--- toggleDuty() -- Player receives a notification of their new duty status.
|
||||||
--- ```
|
--- ```
|
||||||
function toggleDuty()
|
function toggleDuty()
|
||||||
onDuty = not onDuty
|
|
||||||
if isStarted(QBExport) or isStarted(QBXExport) then
|
if isStarted(QBExport) or isStarted(QBXExport) then
|
||||||
TriggerServerEvent("QBCore:ToggleDuty")
|
TriggerServerEvent("QBCore:ToggleDuty")
|
||||||
|
Wait(100)
|
||||||
|
onDuty = getPlayer().onDuty
|
||||||
elseif isStarted(RSGExport) then
|
elseif isStarted(RSGExport) then
|
||||||
TriggerServerEvent("RSGCore:ToggleDuty")
|
TriggerServerEvent("RSGCore:ToggleDuty")
|
||||||
|
Wait(100)
|
||||||
|
onDuty = getPlayer().onDuty
|
||||||
else
|
else
|
||||||
if onDuty then
|
if onDuty then
|
||||||
triggerNotify(nil, "Now on duty", "success")
|
triggerNotify(nil, "Now on duty", "success")
|
||||||
@@ -106,6 +111,15 @@ function toggleDuty()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Framework specific functions to keep duty status synced
|
||||||
|
RegisterNetEvent("QBCore:Client:OnJobUpdate", function(JobInfo) onDuty = JobInfo.onduty end)
|
||||||
|
RegisterNetEvent("QBCore:Client:SetDuty", function(duty) onDuty = duty end)
|
||||||
|
|
||||||
|
RegisterNetEvent("qbx_core:client:onJobUpdate", function(JobInfo) onDuty = JobInfo.onduty end)
|
||||||
|
|
||||||
|
RegisterNetEvent("RSGCore:Client:OnJobUpdate", function(JobInfo) onDuty = JobInfo.onduty end)
|
||||||
|
RegisterNetEvent("RSGCore:Client:SetDuty", function(duty) onDuty = duty end)
|
||||||
|
|
||||||
-------------------------------------------------------------
|
-------------------------------------------------------------
|
||||||
-- Interaction Functions
|
-- Interaction Functions
|
||||||
-------------------------------------------------------------
|
-------------------------------------------------------------
|
||||||
|
|||||||
Reference in New Issue
Block a user