Tidy up onPlayerLoaded for all frameworks

This commit is contained in:
Jim Shield
2025-06-20 21:32:08 +01:00
parent 17db5aa31a
commit 74e6a679e2

View File

@@ -47,22 +47,21 @@ function onPlayerLoaded(func, onStart)
if isStarted(QBExport) or isStarted(QBXExport) then if isStarted(QBExport) or isStarted(QBXExport) then
onPlayerFramework = QBExport onPlayerFramework = QBExport
AddEventHandler('QBCore:Client:OnPlayerLoaded', tempFunc) RegisterNetEvent('QBCore:Client:OnPlayerLoaded', tempFunc)
elseif isStarted(ESXExport) then elseif isStarted(ESXExport) then
onPlayerFramework = ESXExport onPlayerFramework = ESXExport
AddEventHandler('esx:playerLoaded', function() RegisterNetEvent('esx:playerLoaded', function()
if waitForSharedLoad() then if waitForSharedLoad() then
if isStarted(ESXExport) then Wait(1000) end
tempFunc() tempFunc()
end end
end end
) )
elseif isStarted(OXCoreExport) then elseif isStarted(OXCoreExport) then
onPlayerFramework = OXCoreExport onPlayerFramework = OXCoreExport
AddEventHandler('ox:playerLoaded', tempFunc) RegisterNetEvent('ox:playerLoaded', tempFunc)
elseif isStarted(RSGExport) then elseif isStarted(RSGExport) then
onPlayerFramework = RSGExport onPlayerFramework = RSGExport
AddEventHandler('RSGCore:Client:OnPlayerLoaded', tempFunc) RegisterNetEvent('RSGCore:Client:OnPlayerLoaded', tempFunc)
end end
if onPlayerFramework ~= "" then if onPlayerFramework ~= "" then
@@ -84,10 +83,10 @@ end
--- ``` --- ```
function onPlayerUnload(func) function onPlayerUnload(func)
RegisterNetEvent('QBCore:Client:OnPlayerUnload', function() func() end) RegisterNetEvent('QBCore:Client:OnPlayerUnload', function() func() end)
AddEventHandler('ox:playerLogout', function() func() end) RegisterNetEvent('ox:playerLogout', function() func() end)
AddEventHandler('RSGCore:Client:OnPlayerUnload', function() func() end) RegisterNetEvent('RSGCore:Client:OnPlayerUnload', function() func() end)
--AddEventHandler('esx:playerLogout', function() func() end) RegisterNetEvent('esx:onPlayerLogout', function() func() end)
-- ^ Only server side for now, need a way to send it to client if not already available -- ^ Only server side for now, need a way to send it to client if not already available
end end