Update on cache and config
This commit is contained in:
1 parent
a3a06d4ae9
commit
87b51e13e0
3 files changed
+108
-31
No files matched your search
Vendored
+33
-6
@@ -1,15 +1,31 @@
|
||||
Cache = Require("lib/cache/shared/cache.lua")
|
||||
local PlayerPedId = PlayerPedId
|
||||
local GetVehiclePedIsIn = GetVehiclePedIsIn
|
||||
local GetVehicleMaxNumberOfPassengers = GetVehicleMaxNumberOfPassengers
|
||||
local GetPedInVehicleSeat = GetPedInVehicleSeat
|
||||
local GetPlayerServerId = GetPlayerServerId
|
||||
local GetSelectedPedWeapon = GetSelectedPedWeapon
|
||||
local PlayerId = PlayerId
|
||||
|
||||
|
||||
-- Comparison functions for client-side state
|
||||
|
||||
--- Get the player's ped ID
|
||||
---@return integer
|
||||
local function GetPed()
|
||||
return PlayerPedId()
|
||||
end
|
||||
|
||||
--- Get the vehicle the player is in, if any
|
||||
---@return integer | nil
|
||||
local function GetVehicle()
|
||||
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)
|
||||
end
|
||||
|
||||
--- Get the seat of the player in the vehicle if the vehicle is occupied
|
||||
---@return integer | nil
|
||||
local function GetVehicleSeat()
|
||||
local vehicle = Cache.Get("Vehicle")
|
||||
if not vehicle then return end
|
||||
@@ -22,15 +38,26 @@ local function GetVehicleSeat()
|
||||
end
|
||||
end
|
||||
|
||||
---Get The Server ID of the player
|
||||
---@return integer | nil
|
||||
local function GetServerId()
|
||||
local ped <const> = PlayerId()
|
||||
if not ped then return end -- Return unarmed hash if no ped
|
||||
return GetPlayerServerId(ped)
|
||||
end
|
||||
|
||||
--- Get the current weapon of the player
|
||||
--- @return integer | nil
|
||||
local function GetWeapon()
|
||||
local ped = Cache.Get("Ped")
|
||||
if not ped then return end -- Return unarmed hash if no ped
|
||||
return GetSelectedPedWeapon(ped)
|
||||
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
|
||||
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
|
||||
Cache.Create("ServerId", GetServerId, 1000) -- Check server ID every second
|
||||
|
||||
return Cache
|
||||
return Cache
|
||||
Reference in new issue
Block a user