This commit is contained in:
Lorraxs 2024-01-15 10:46:41 +07:00
parent 02a5f0d8af
commit 01155f838d
3 changed files with 13 additions and 13 deletions

View File

@ -34,13 +34,12 @@ shared_scripts {
} }
--[[ client_scripts { client_scripts {
"client/classes/*", "client/classes/*",
"client/impl/*" "client/impl/*"
} ]] }
server_script { server_script {
'@oxmysql/lib/MySQL.lua', '@oxmysql/lib/MySQL.lua',
"server/classes/*", "server/classes/*",
"server/impl/*" "server/impl/*"
} }

View File

@ -292,6 +292,7 @@ function NewImpl(name)
local impl = Impl:extend({ local impl = Impl:extend({
name = name, name = name,
config = Config[name] or {}, config = Config[name] or {},
implType = "impl"
}) })
main:RegisterImpl(name, impl) main:RegisterImpl(name, impl)
return impl return impl

View File

@ -181,7 +181,7 @@ function Main:CheckValidImpl(name, impl)
end end
function Main:RegisterImpl(name, impl) function Main:RegisterImpl(name, impl)
if Config.EnableModules[name] == nil or not Config.EnableModules[name].enabled then if impl.implType == "impl" and (Config.EnableModules[name] == nil or not Config.EnableModules[name].enabled) then
self:LogWarning("Impl %s not enabled", name) self:LogWarning("Impl %s not enabled", name)
return return
end end
@ -225,25 +225,25 @@ function Main:InitImpl()
end end
end end
for name, impl in pairs(self.impls) do for name, impl in pairs(self.impls) do
if Config.EnableModules[name] and Config.EnableModules[name].priority == 1 then if impl.implType ~= "impl" or (Config.EnableModules[name] and Config.EnableModules[name].priority == 1) then
self.initializedImpls[name] = impl(self) self.initializedImpls[name] = impl(self)
end end
end end
self:LogInfo("All priority 1 initialized") self:LogInfo("All priority 1 initialized")
for name, impl in pairs(self.initializedImpls) do for name, impl in pairs(self.initializedImpls) do
if Config.EnableModules[name] and Config.EnableModules[name].priority == 1 then if impl.implType ~= "impl" or (Config.EnableModules[name] and Config.EnableModules[name].priority == 1) then
impl:OnReady() impl:OnReady()
end end
end end
else else
for name, impl in pairs(self.impls) do for name, impl in pairs(self.impls) do
if Config.EnableModules[name] and Config.EnableModules[name].priority == 1 then if impl.implType ~= "impl" or (Config.EnableModules[name] and Config.EnableModules[name].priority == 1) then
self.initializedImpls[name] = impl(self) self.initializedImpls[name] = impl(self)
end end
end end
self:LogInfo("All priority 1 initialized") self:LogInfo("All priority 1 initialized")
for name, impl in pairs(self.initializedImpls) do for name, impl in pairs(self.initializedImpls) do
if Config.EnableModules[name] and Config.EnableModules[name].priority == 1 then if impl.implType ~= "impl" or (Config.EnableModules[name] and Config.EnableModules[name].priority == 1) then
impl:OnReady() impl:OnReady()
end end
end end
@ -333,7 +333,7 @@ end
main = Main:Init() main = Main:Init()
local origAddEventHandler = AddEventHandler --[[ local origAddEventHandler = AddEventHandler
function AddEventHandler(eventName, ...) function AddEventHandler(eventName, ...)
if RegisteredEvents[eventName] then if RegisteredEvents[eventName] then
main:LogWarning("Event %s already registered. Removing", eventName) main:LogWarning("Event %s already registered. Removing", eventName)
@ -351,7 +351,7 @@ function RegisterNetEvent(eventName, ...)
end end
RegisteredEvents[eventName] = origRegisterNetEvent(eventName, ...) RegisteredEvents[eventName] = origRegisterNetEvent(eventName, ...)
return RegisteredEvents[eventName] return RegisteredEvents[eventName]
end end ]]
Citizen.CreateThread(function() Citizen.CreateThread(function()
while GetGameTimer() < main.lastTimeImplRegistered + 1000 do while GetGameTimer() < main.lastTimeImplRegistered + 1000 do