From b23905b279a6c14fd91f11ff2c645640cfb50d66 Mon Sep 17 00:00:00 2001 From: Lorraxs Date: Sat, 24 Feb 2024 09:53:57 +0700 Subject: [PATCH] add dependence config --- config.lua | 2 ++ main.lua | 14 ++++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/config.lua b/config.lua index afd41fe..9cb2b26 100644 --- a/config.lua +++ b/config.lua @@ -1,5 +1,7 @@ Config = {} +Config.Dependencies = {} -- Reqired resources loaded to start + Config.Settings = { locale = {} } diff --git a/main.lua b/main.lua index 171a88d..be68701 100644 --- a/main.lua +++ b/main.lua @@ -218,6 +218,15 @@ function Main:RegisterImpl(name, impl) end function Main:InitImpl() + if Config.Dependencies then + for k, v in ipairs(Config.Dependencies) do + local p = promise.new() + TriggerEvent(('%s:onReady'):format(v), function() + p:resolve() + end) + Citizen.Await(p) + end + end if not IsDuplicityVersion() then if Config.ClientLazyLoad then for k, v in pairs(Config.EnableModules) do @@ -342,8 +351,9 @@ function Main:Exports() end main = Main:Init() - -AddEventHandler(("%s:onReady"):format(GetCurrentGameName()), function(handler) +AddEventHandler(("%s:onReady"):format(GetCurrentResourceName()), function(handler) + local invokingResource = GetInvokingResource() + main:LogInfo(invokingResource) main:ListenOnReady(handler) end)