Update main.lua
This commit is contained in:
parent
9a64a0d00f
commit
77dc46460b
39
main.lua
39
main.lua
|
@ -3,6 +3,12 @@ if Config.Framework == 'esx' then
|
||||||
Framework = exports["es_extended"]:getSharedObject()
|
Framework = exports["es_extended"]:getSharedObject()
|
||||||
elseif Config.Framework == "qb" then
|
elseif Config.Framework == "qb" then
|
||||||
Framework = exports['qb-core']:GetCoreObject()
|
Framework = exports['qb-core']:GetCoreObject()
|
||||||
|
else
|
||||||
|
Framework = {}
|
||||||
|
Framework.Functions = {}
|
||||||
|
Framework.Functions.GetPlayerData = function()
|
||||||
|
return {}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
Main = {}
|
Main = {}
|
||||||
|
@ -32,7 +38,6 @@ function Main:Init()
|
||||||
o.playerHeading = GetEntityHeading(o.playerPed)
|
o.playerHeading = GetEntityHeading(o.playerPed)
|
||||||
o.playerServerId = GetPlayerServerId(o.playerId)
|
o.playerServerId = GetPlayerServerId(o.playerId)
|
||||||
o:Thread1()
|
o:Thread1()
|
||||||
|
|
||||||
else
|
else
|
||||||
o.ClientImpls = {}
|
o.ClientImpls = {}
|
||||||
for k, v in pairs(Config.EnableModules) do
|
for k, v in pairs(Config.EnableModules) do
|
||||||
|
@ -57,6 +62,7 @@ function Main:Init()
|
||||||
o:RegisterEvents()
|
o:RegisterEvents()
|
||||||
return o
|
return o
|
||||||
end
|
end
|
||||||
|
|
||||||
if not IsDuplicityVersion() then
|
if not IsDuplicityVersion() then
|
||||||
function Main:Thread1()
|
function Main:Thread1()
|
||||||
Citizen.CreateThread(function()
|
Citizen.CreateThread(function()
|
||||||
|
@ -76,7 +82,7 @@ function Main:RegisterCommands()
|
||||||
RegisterCommand("toggledebug:" .. ResourceName, function(source, args, rawCommand)
|
RegisterCommand("toggledebug:" .. ResourceName, function(source, args, rawCommand)
|
||||||
Config.Debug = not Config.Debug
|
Config.Debug = not Config.Debug
|
||||||
self:LogInfo("Debug %s", Config.Debug)
|
self:LogInfo("Debug %s", Config.Debug)
|
||||||
end)
|
end, false)
|
||||||
RegisterCommand("toggledev:" .. ResourceName, function(source, args, rawCommand)
|
RegisterCommand("toggledev:" .. ResourceName, function(source, args, rawCommand)
|
||||||
Config.Dev = not Config.Dev
|
Config.Dev = not Config.Dev
|
||||||
self:LogInfo("Dev %s", Config.Dev)
|
self:LogInfo("Dev %s", Config.Dev)
|
||||||
|
@ -86,15 +92,16 @@ function Main:RegisterCommands()
|
||||||
isDev = Config.Dev,
|
isDev = Config.Dev,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
end)
|
end, false)
|
||||||
RegisterCommand("implinfo:" .. ResourceName, function(source, args, rawCommand)
|
RegisterCommand("implinfo:" .. ResourceName, function(source, args, rawCommand)
|
||||||
self:ImplInfo()
|
self:ImplInfo()
|
||||||
end)
|
end, false)
|
||||||
RegisterCommand("test", function()
|
RegisterCommand("test", function()
|
||||||
TriggerEvent("test")
|
TriggerEvent("test")
|
||||||
end)
|
end, false)
|
||||||
else
|
else
|
||||||
RegisterCommand("reload:" .. ResourceName, function(source, args, rawCommand)
|
RegisterCommand("reload:" .. ResourceName, function(source, args, rawCommand)
|
||||||
|
if Config.ClientLazyLoad == false then return print("Lazyload was disabled") end
|
||||||
local implName = args[1]
|
local implName = args[1]
|
||||||
local mode = args[2]
|
local mode = args[2]
|
||||||
if mode == nil then
|
if mode == nil then
|
||||||
|
@ -206,6 +213,7 @@ end
|
||||||
|
|
||||||
function Main:InitImpl()
|
function Main:InitImpl()
|
||||||
if not IsDuplicityVersion() then
|
if not IsDuplicityVersion() then
|
||||||
|
if Config.ClientLazyLoad then
|
||||||
for k, v in pairs(Config.EnableModules) do
|
for k, v in pairs(Config.EnableModules) do
|
||||||
if v.enabled and v.priority == 1 and v.client then
|
if v.enabled and v.priority == 1 and v.client then
|
||||||
self:LogInfo("Loading %s", k)
|
self:LogInfo("Loading %s", k)
|
||||||
|
@ -227,6 +235,19 @@ function Main:InitImpl()
|
||||||
impl:OnReady()
|
impl:OnReady()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
for name, impl in pairs(self.impls) do
|
||||||
|
if Config.EnableModules[name] and Config.EnableModules[name].priority == 1 then
|
||||||
|
self.initializedImpls[name] = impl(self)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
self:LogInfo("All priority 1 initialized")
|
||||||
|
for name, impl in pairs(self.initializedImpls) do
|
||||||
|
if Config.EnableModules[name] and Config.EnableModules[name].priority == 1 then
|
||||||
|
impl:OnReady()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
else
|
else
|
||||||
for name, impl in pairs(self.impls) do
|
for name, impl in pairs(self.impls) do
|
||||||
self.initializedImpls[name] = impl(self)
|
self.initializedImpls[name] = impl(self)
|
||||||
|
@ -242,11 +263,17 @@ function Main:InitImplAfterPlayerLoaded()
|
||||||
for k, v in pairs(Config.EnableModules) do
|
for k, v in pairs(Config.EnableModules) do
|
||||||
if v.enabled and v.priority == 2 and v.client then
|
if v.enabled and v.priority == 2 and v.client then
|
||||||
self:LogInfo("Loading %s", k)
|
self:LogInfo("Loading %s", k)
|
||||||
|
if Config.ClientLazyLoad then
|
||||||
local source = lib.callback.await(ResourceName .. ":getClientImpl", false, k)
|
local source = lib.callback.await(ResourceName .. ":getClientImpl", false, k)
|
||||||
if source ~= nil then
|
if source ~= nil then
|
||||||
self:LogInfo("Loaded %s", k)
|
self:LogInfo("Loaded %s", k)
|
||||||
load(source)()
|
load(source)()
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
if self.initializedImpls[k] then
|
||||||
|
self.initializedImpls[k]:OnReady()
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -291,7 +318,6 @@ function Main:ImplCall(name, func, ...)
|
||||||
return impl[func](impl, ...)
|
return impl[func](impl, ...)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function Main:ImplInfo()
|
function Main:ImplInfo()
|
||||||
for name, impl in pairs(self.impls) do
|
for name, impl in pairs(self.impls) do
|
||||||
local debug = debug.getinfo(impl.OnReady, "S")
|
local debug = debug.getinfo(impl.OnReady, "S")
|
||||||
|
@ -328,7 +354,6 @@ function RegisterNetEvent(eventName, ...)
|
||||||
end
|
end
|
||||||
|
|
||||||
Citizen.CreateThread(function()
|
Citizen.CreateThread(function()
|
||||||
|
|
||||||
while GetGameTimer() < main.lastTimeImplRegistered + 1000 do
|
while GetGameTimer() < main.lastTimeImplRegistered + 1000 do
|
||||||
Citizen.Wait(0)
|
Citizen.Wait(0)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user