cache fixed
This commit is contained in:
1 parent
6b660d8084
commit
d89b087e4d
2 files changed
+6
-7
No files matched your search
Vendored
+6
-6
@@ -12,13 +12,13 @@ local PlayerId = PlayerId
|
|||||||
|
|
||||||
--- Get the player's ped ID
|
--- Get the player's ped ID
|
||||||
---@return integer
|
---@return integer
|
||||||
local function GetPed()
|
function GetPed()
|
||||||
return PlayerPedId()
|
return PlayerPedId()
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Get the vehicle the player is in, if any
|
--- Get the vehicle the player is in, if any
|
||||||
---@return integer | nil
|
---@return integer | nil
|
||||||
local function GetVehicle()
|
function GetVehicle()
|
||||||
local ped = Cache.Get("Ped") -- Use cached ped for efficiency
|
local ped = Cache.Get("Ped") -- Use cached ped for efficiency
|
||||||
if not ped then return end -- Or handle error/default case
|
if not ped then return end -- Or handle error/default case
|
||||||
return GetVehiclePedIsIn(ped, false)
|
return GetVehiclePedIsIn(ped, false)
|
||||||
@@ -26,7 +26,7 @@ end
|
|||||||
|
|
||||||
--- Get the seat of the player in the vehicle if the vehicle is occupied
|
--- Get the seat of the player in the vehicle if the vehicle is occupied
|
||||||
---@return integer | nil
|
---@return integer | nil
|
||||||
local function GetVehicleSeat()
|
function GetVehicleSeat()
|
||||||
local vehicle = Cache.Get("Vehicle")
|
local vehicle = Cache.Get("Vehicle")
|
||||||
if not vehicle then return end
|
if not vehicle then return end
|
||||||
local ped = Cache.Get("Ped")
|
local ped = Cache.Get("Ped")
|
||||||
@@ -40,7 +40,7 @@ end
|
|||||||
|
|
||||||
---Get The Server ID of the player
|
---Get The Server ID of the player
|
||||||
---@return integer | nil
|
---@return integer | nil
|
||||||
local function GetServerId()
|
function GetServerId()
|
||||||
local ped <const> = PlayerId()
|
local ped <const> = PlayerId()
|
||||||
if not ped then return end -- Return unarmed hash if no ped
|
if not ped then return end -- Return unarmed hash if no ped
|
||||||
return GetPlayerServerId(ped)
|
return GetPlayerServerId(ped)
|
||||||
@@ -48,7 +48,7 @@ end
|
|||||||
|
|
||||||
--- Get the current weapon of the player
|
--- Get the current weapon of the player
|
||||||
--- @return integer | nil
|
--- @return integer | nil
|
||||||
local function GetWeapon()
|
function GetWeapon()
|
||||||
local ped = Cache.Get("Ped")
|
local ped = Cache.Get("Ped")
|
||||||
if not ped then return end -- Return unarmed hash if no ped
|
if not ped then return end -- Return unarmed hash if no ped
|
||||||
return GetSelectedPedWeapon(ped)
|
return GetSelectedPedWeapon(ped)
|
||||||
@@ -57,7 +57,7 @@ end
|
|||||||
Cache.Create("Ped", GetPed, 1000) -- Check ped every second (adjust as needed)
|
Cache.Create("Ped", GetPed, 1000) -- Check ped every second (adjust as needed)
|
||||||
Cache.Create("Vehicle", GetVehicle, 500) -- Check vehicle every 500ms
|
Cache.Create("Vehicle", GetVehicle, 500) -- Check vehicle every 500ms
|
||||||
Cache.Create("Seat", GetVehicleSeat, 500) -- Check if in vehicle every 500ms
|
Cache.Create("Seat", GetVehicleSeat, 500) -- Check if in vehicle every 500ms
|
||||||
Cache.Create("Weapon", GetWeapon, 250) -- Check weapon every 250ms
|
Cache.Create("Weapon", GetWeapon , 250) -- Check weapon every 250ms
|
||||||
Cache.Create("ServerId", GetServerId, 1000) -- Check server ID every second
|
Cache.Create("ServerId", GetServerId, 1000) -- Check server ID every second
|
||||||
|
|
||||||
return Cache
|
return Cache
|
||||||
Vendored
-1
@@ -57,7 +57,6 @@ end
|
|||||||
function Cache.Create(name, compare, waitTime)
|
function Cache.Create(name, compare, waitTime)
|
||||||
assert(name, "Cache name is required.")
|
assert(name, "Cache name is required.")
|
||||||
assert(compare, "Comparison function is required.")
|
assert(compare, "Comparison function is required.")
|
||||||
assert(type(compare) == "function", "Comparison function must be a function.")
|
|
||||||
local _name = tostring(name) -- Ensure name is a string
|
local _name = tostring(name) -- Ensure name is a string
|
||||||
local cache = Cache.Caches[_name]
|
local cache = Cache.Caches[_name]
|
||||||
if cache and cache.Compare == compare then
|
if cache and cache.Compare == compare then
|
||||||
|
|||||||
Reference in new issue
Block a user