mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-11-19 18:28:33 +00:00
refactor(cache): save seat index instead of driver
This commit is contained in:
1 parent
f8d68df5e9
commit
b37e9f772f
1 file changed
+11
-6
Vendored
+11
-6
@@ -11,13 +11,18 @@ function cache:getVehicle()
|
||||
local vehicle = GetVehiclePedIsIn(self.ped, false)
|
||||
if vehicle > 0 then
|
||||
if self:set('vehicle', vehicle) then
|
||||
if GetPedInVehicleSeat(vehicle, -1) == self.ped then
|
||||
self:set('driver', true)
|
||||
else
|
||||
self:set('driver', false)
|
||||
local seats = GetVehicleMaxNumberOfPassengers(vehicle) - 1
|
||||
local GetPedInVehicleSeat = GetPedInVehicleSeat
|
||||
for i = -1, seats do
|
||||
if GetPedInVehicleSeat(vehicle, i) == self.ped then
|
||||
return self:set('seat', i)
|
||||
end
|
||||
end
|
||||
end
|
||||
else self:set('vehicle', nil) end
|
||||
else
|
||||
self:set('vehicle', false)
|
||||
self:set('seat', false)
|
||||
end
|
||||
end
|
||||
|
||||
function cache:onFoot()
|
||||
@@ -55,7 +60,7 @@ CreateThread(function()
|
||||
-- cache:inVehicle()
|
||||
-- end
|
||||
|
||||
if cache.update then
|
||||
if next(update) then
|
||||
TriggerEvent('lualib:updateCache', update)
|
||||
table.wipe(update)
|
||||
end
|
||||
|
||||
Reference in new issue
Block a user