mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-19 07:56:02 +01:00
fix(cache/client): change vehicle getter
GetVehiclePedIsIn isn't working with the latest build. Use GetVehiclePedIsUsing instead. Removed an unused cached value (coords). Removed the num iterator used for cache:getVehicle to slow its frequency.
This commit is contained in:
15
resource/cache/client.lua
vendored
15
resource/cache/client.lua
vendored
@@ -2,12 +2,12 @@ local cache = {}
|
|||||||
cache.playerId = PlayerId()
|
cache.playerId = PlayerId()
|
||||||
cache.serverId = GetPlayerServerId(cache.playerId)
|
cache.serverId = GetPlayerServerId(cache.playerId)
|
||||||
|
|
||||||
local GetVehiclePedIsIn = GetVehiclePedIsIn
|
local GetVehiclePedIsUsing = GetVehiclePedIsUsing
|
||||||
local GetPedInVehicleSeat = GetPedInVehicleSeat
|
local GetPedInVehicleSeat = GetPedInVehicleSeat
|
||||||
local GetVehicleMaxNumberOfPassengers = GetVehicleMaxNumberOfPassengers
|
local GetVehicleMaxNumberOfPassengers = GetVehicleMaxNumberOfPassengers
|
||||||
|
|
||||||
function cache:getVehicle()
|
function cache:getVehicle()
|
||||||
local vehicle = GetVehiclePedIsIn(self.ped, false)
|
local vehicle = GetVehiclePedIsUsing(self.ped)
|
||||||
if vehicle > 0 then
|
if vehicle > 0 then
|
||||||
self:set('vehicle', vehicle)
|
self:set('vehicle', vehicle)
|
||||||
|
|
||||||
@@ -34,19 +34,10 @@ function cache:set(key, value)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local GetEntityCoords = GetEntityCoords
|
|
||||||
|
|
||||||
CreateThread(function()
|
CreateThread(function()
|
||||||
local num = 1
|
|
||||||
while true do
|
while true do
|
||||||
num += 1
|
|
||||||
cache:set('ped', PlayerPedId())
|
cache:set('ped', PlayerPedId())
|
||||||
|
cache:getVehicle()
|
||||||
if num > 1 then
|
|
||||||
cache.coords = GetEntityCoords(cache.ped)
|
|
||||||
cache:getVehicle()
|
|
||||||
num = 0
|
|
||||||
end
|
|
||||||
|
|
||||||
if next(update) then
|
if next(update) then
|
||||||
TriggerEvent('ox_lib:updateCache', update)
|
TriggerEvent('ox_lib:updateCache', update)
|
||||||
|
|||||||
Reference in New Issue
Block a user