fix(cache): update seat when shuffling

This commit is contained in:
Linden
2022-03-16 06:08:18 +00:00
parent 33681a1557
commit 913c51307a

View File

@@ -1,12 +1,13 @@
local cache = {} local cache = {}
local GetPedInVehicleSeat = GetPedInVehicleSeat
function cache:getVehicle() function cache:getVehicle()
local vehicle = GetVehiclePedIsIn(self.ped, false) local vehicle = GetVehiclePedIsIn(self.ped, false)
if vehicle > 0 then if vehicle > 0 then
if self:set('vehicle', vehicle) then self:set('vehicle', vehicle)
local seats = GetVehicleMaxNumberOfPassengers(vehicle) - 1
local GetPedInVehicleSeat = GetPedInVehicleSeat if not cache.seat or GetPedInVehicleSeat(vehicle, cache.seat) ~= cache.ped then
for i = -1, seats do for i = -1, GetVehicleMaxNumberOfPassengers(vehicle) - 1 do
if GetPedInVehicleSeat(vehicle, i) == self.ped then if GetPedInVehicleSeat(vehicle, i) == self.ped then
return self:set('seat', i) return self:set('seat', i)
end end
@@ -47,6 +48,7 @@ CreateThread(function()
while true do while true do
num += 1 num += 1
cache:set('ped', PlayerPedId()) cache:set('ped', PlayerPedId())
print(cache.seat)
if num > 1 then if num > 1 then
cache.coords = GetEntityCoords(cache.ped) cache.coords = GetEntityCoords(cache.ped)