From 515bf37effa6d6e408fd79e2fed2da5e629dab0c Mon Sep 17 00:00:00 2001 From: Taso Date: Tue, 30 Nov 2021 12:43:13 -0500 Subject: [PATCH] feat(GetCoreObject): implicit restart SharedObject assignment --- import.lua | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 import.lua diff --git a/import.lua b/import.lua new file mode 100644 index 0000000..775e253 --- /dev/null +++ b/import.lua @@ -0,0 +1,16 @@ +-- This file primarily is for implicit handling for restarts of `qb-core` +-- Whenever qb-core is restarted, the shared object table containing +-- function refs becomes invalid. To solve this, we must reassign our +-- table again with the update function ref pointers at resource start + +-- Any changes to the resource name, means this handler won't work anymore + +QBCore = exports['qb-core']:GetCoreObject() + +AddEventHandler('onResourceStart', function(resName) + -- We only want to reassign funcref table, + -- when qb-core resource status changes. + if resName ~= 'qb-core' then return end + -- Lets refresh local table with updated func refs + QBCore = exports['qb-core']:GetCoreObject() +end) \ No newline at end of file