From ae7f0dc0d822bb245034e1a8d2966dada389c82f Mon Sep 17 00:00:00 2001 From: Andyyy7666 <86536434+Andyyy7666@users.noreply.github.com> Date: Sun, 24 Sep 2023 04:46:24 +0200 Subject: [PATCH] fix(client/vehicle): locking issues --- client/vehicle.lua | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/client/vehicle.lua b/client/vehicle.lua index f10aec6..0e94b37 100644 --- a/client/vehicle.lua +++ b/client/vehicle.lua @@ -318,9 +318,8 @@ local dontLock = { AddStateBagChangeHandler("locked", nil, function(bagName, key, value, reserved, replicated) local entity = GetEntityFromStateBagName(bagName) - if entity == 0 then return end - if dontLock[GetVehicleClass(entity)] then return end - + if entity == 0 or value == nil or dontLock[GetVehicleClass(entity)] then return end + if value then -- SetVehicleDoorsLockedForAllPlayers(entity, true) return SetVehicleDoorsLocked(entity, 2) @@ -330,7 +329,6 @@ AddStateBagChangeHandler("locked", nil, function(bagName, key, value, reserved, while GetVehiclePedIsEntering(cache.ped) == entity do Wait(10) end -- SetVehicleDoorsLockedForAllPlayers(entity, false) - if value == nil then return end SetVehicleDoorsLocked(entity, 0) end) end) @@ -403,7 +401,7 @@ local function getNearestVehicle(hasKeysForOnly) local function setNearestVehicle(veh) if hasKeysForOnly and not hasVehicleKeys(veh.vehicle) then return end local nearestDist = nearestVeh.dist - local dist = #(GetEntityCoords(cache.ped)-veh.coords) + local dist = #(coords-veh.coords) if not nearestDist or dist < nearestDist then nearestVeh.dist = dist nearestVeh.coords = veh.coords