Skip to content

Commit

Permalink
fix(modules/lib): deleting vehicle when unable to find owner or set v…
Browse files Browse the repository at this point in the history
…ehicle properties
  • Loading branch information
Manason committed Jul 5, 2024
1 parent a50594f commit 874bcb7
Showing 1 changed file with 18 additions and 17 deletions.
35 changes: 18 additions & 17 deletions modules/lib.lua
Original file line number Diff line number Diff line change
Expand Up @@ -267,17 +267,17 @@ if isServer then
SetPedIntoVehicle(ped, veh, -1)
end

local foundOwner = lib.waitFor(function()
local owner = NetworkGetEntityOwner(veh)
if ped then
--- the owner should be transferred to the driver
if owner == NetworkGetEntityOwner(ped) then return true end
else
if owner ~= -1 then return true end
end
end, 'client never set as owner', 5000)

if not foundOwner then
if not pcall(function()
lib.waitFor(function()
local owner = NetworkGetEntityOwner(veh)
if ped then
--- the owner should be transferred to the driver
if owner == NetworkGetEntityOwner(ped) then return true end
else
if owner ~= -1 then return true end
end
end, 'client never set as owner', 5000)
end) then
DeleteEntity(veh)
error('Deleting vehicle which timed out finding an owner')
end
Expand All @@ -287,12 +287,13 @@ if isServer then

if props and type(props) == 'table' and props.plate then
state:set('setVehicleProperties', props, true)
local success = lib.waitFor(function()
if qbx.string.trim(GetVehicleNumberPlateText(veh)) == qbx.string.trim(props.plate) then
return true
end
end, 'Failed to set vehicle properties within 5 seconds', 5000)
if not success then
if not pcall(function()
lib.waitFor(function()
if qbx.string.trim(GetVehicleNumberPlateText(veh)) == qbx.string.trim(props.plate) then
return true
end
end, 'Failed to set vehicle properties within 5 seconds', 5000)
end) then
DeleteEntity(veh)
error('Deleting vehicle which timed out setting vehicle properties')
end
Expand Down

0 comments on commit 874bcb7

Please sign in to comment.