feat(GetCoreObject): implicit restart SharedObject assignment

This commit is contained in:
Taso
2021-11-30 12:43:13 -05:00
parent 1cdf3a5611
commit 515bf37eff
+16
View File
@@ -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)