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