Skip to content

Commit b535158

Browse files
committed
fix(scripting): use onResourceStart for exports cache clearing
1 parent 3158237 commit b535158

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

data/shared/citizen/scripting/lua/scheduler.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,8 @@ end
655655

656656
-- Remove cache when resource stop to avoid calling unexisting exports
657657
local function lazyEventHandler() -- lazy initializer so we don't add an event we don't need
658-
AddEventHandler(('on%sResourceStop'):format(isDuplicityVersion and 'Server' or 'Client'), function(resource)
658+
-- Use onResourceStop to not break cached exports for onResourceStart
659+
AddEventHandler('onResourceStop', function(resource)
659660
exportsCallbackCache[resource] = {}
660661
end)
661662

data/shared/citizen/scripting/v8/main.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,8 @@ const EXT_LOCALFUNCREF = 11;
568568
}
569569
});
570570

571-
on(`on${eventType}ResourceStop`, (resource) => {
571+
// clear cache with onResourceStop to not break cached exports for onResourceStart
572+
on('onResourceStop', (resource) => {
572573
exportsCallbackCache[resource] = {};
573574
});
574575

0 commit comments

Comments
 (0)