Cache fix on initial load up of server
Issue with cache where it didnt load the default cache (ped, vehicle, seat and weapon) on initial loadup of server This is a pretty critical bug and should be tested and pushed asap
This commit is contained in:
1 parent
01d2f4e1f6
commit
df0dedd46c
2 files changed
+9
-13
No files matched your search
Vendored
+5
-9
@@ -1,5 +1,4 @@
|
||||
Cache = Cache or Require("lib/cache/shared/cache.lua")
|
||||
|
||||
Cache = Require("lib/cache/shared/cache.lua")
|
||||
-- Comparison functions for client-side state
|
||||
local function GetPed()
|
||||
return PlayerPedId()
|
||||
@@ -29,12 +28,9 @@ local function GetWeapon()
|
||||
return GetSelectedPedWeapon(ped)
|
||||
end
|
||||
|
||||
AddEventHandler('onResourceStart', function(resource)
|
||||
if resource ~= GetCurrentResourceName() then return end
|
||||
Cache.Create("Ped", GetPed, 1000) -- Check ped every second (adjust as needed)
|
||||
Cache.Create("Vehicle", GetVehicle, 500) -- Check vehicle every 500ms
|
||||
Cache.Create("Seat", GetVehicleSeat, 500) -- Check if in vehicle every 500ms
|
||||
Cache.Create("Weapon", GetWeapon, 250) -- Check weapon every 250ms
|
||||
end)
|
||||
Cache.Create("Ped", GetPed, 1000) -- Check ped every second (adjust as needed)
|
||||
Cache.Create("Vehicle", GetVehicle, 500) -- Check vehicle every 500ms
|
||||
Cache.Create("Seat", GetVehicleSeat, 500) -- Check if in vehicle every 500ms
|
||||
Cache.Create("Weapon", GetWeapon, 250) -- Check weapon every 250ms
|
||||
|
||||
return Cache
|
||||
Vendored
+4
-4
@@ -1,7 +1,6 @@
|
||||
Cache = {}
|
||||
Cache.Caches = {}
|
||||
|
||||
Cache.LoopRunning = false
|
||||
local Cache = {}
|
||||
Cache.Caches = Cache.Caches or {}
|
||||
Cache.LoopRunning = Cache.LoopRunning or false
|
||||
|
||||
local max = 5000
|
||||
local function StartLoop()
|
||||
@@ -54,6 +53,7 @@ function Cache.Create(name, compare, waitTime)
|
||||
for _, onChange in pairs(Cache.Caches[name].OnChange) do
|
||||
onChange(Cache.Caches[name].Value, nil)
|
||||
end
|
||||
print("Cache created: " .. name .. " with initial value: " .. tostring(Cache.Caches[name].Value))
|
||||
return StartLoop()
|
||||
end
|
||||
|
||||
|
||||
Reference in new issue
Block a user