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:
gononono64 committed 2025-05-02 03:11:06 -05:00
1 parent 01d2f4e1f6
commit df0dedd46c
2 files changed
+9 -13

No files matched your search

+5 -9
View File
@@ -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