perf(cache): check vehicle every second tick

This commit is contained in:
Linden
2022-03-13 03:21:33 +00:00
parent 13c8c29811
commit 35e4bc7509

View File

@@ -43,15 +43,21 @@ function cache:set(key, value)
end
CreateThread(function()
local num = 1
while true do
num += 1
cache:set('ped', PlayerPedId())
cache:getVehicle()
-- if not cache.vehicle then
-- cache:onFoot()
-- else
-- cache:inVehicle()
-- end
if num > 1 then
cache.coords = GetEntityCoords(cache.ped)
cache:getVehicle()
-- if not cache.vehicle then
-- cache:onFoot()
-- else
-- cache:inVehicle()
-- end
num = 0
end
if next(update) then
TriggerEvent('ox_lib:updateCache', update)
@@ -64,4 +70,6 @@ end)
function lib.cache(key)
return cache[key]
end
end
_ENV.cache = cache