refactor(resource/cache): new cache event

Rather than sending a bulk update of cache, trigger different events for
each key.
This commit is contained in:
Linden
2022-07-28 23:09:23 +10:00
parent ef6f780028
commit 39d5bbae3d

View File

@@ -24,12 +24,10 @@ function cache:getVehicle()
end
end
local update = {}
function cache:set(key, value)
if value ~= self[key] then
self[key] = value
update[key] = value
TriggerEvent(('ox_lib:cache:%s'):format(key), value)
return true
end
end
@@ -38,12 +36,6 @@ CreateThread(function()
while true do
cache:set('ped', PlayerPedId())
cache:getVehicle()
if next(update) then
TriggerEvent('ox_lib:updateCache', update)
table.wipe(update)
end
Wait(100)
end
end)