Update main.lua
This commit is contained in:
parent
c2f2511b87
commit
60002cd92a
14
main.lua
14
main.lua
|
@ -30,6 +30,7 @@ function Main:Init()
|
|||
o.impls = {}
|
||||
o.initializedImpls = {}
|
||||
o.lastTimeImplRegistered = 0
|
||||
o.onReadyCallbacks = {}
|
||||
o.ready = false
|
||||
if not IsDuplicityVersion() then
|
||||
o.playerId = PlayerId()
|
||||
|
@ -63,6 +64,11 @@ function Main:Init()
|
|||
return o
|
||||
end
|
||||
|
||||
function Main:ListenOnReady(handler)
|
||||
if self.ready then return handler() end
|
||||
table.insert(self.onReadyCallbacks, handler)
|
||||
end
|
||||
|
||||
if not IsDuplicityVersion() then
|
||||
function Main:Thread1()
|
||||
Citizen.CreateThread(function()
|
||||
|
@ -296,6 +302,10 @@ function Main:InitImplAfterPlayerLoaded()
|
|||
})
|
||||
end
|
||||
self.ready = true
|
||||
for k, v in ipairs(self.onReadyCallbacks) do
|
||||
v()
|
||||
end
|
||||
self.onReadyCallbacks = {}
|
||||
end
|
||||
|
||||
function Main:GetImpl(name)
|
||||
|
@ -333,6 +343,10 @@ end
|
|||
|
||||
main = Main:Init()
|
||||
|
||||
AddEventHandler(("%s:onReady"):format(GetCurrentGameName()), function(handler)
|
||||
main:ListenOnReady(handler)
|
||||
end)
|
||||
|
||||
--[[ local origAddEventHandler = AddEventHandler
|
||||
function AddEventHandler(eventName, ...)
|
||||
if RegisteredEvents[eventName] then
|
||||
|
|
Loading…
Reference in New Issue
Block a user