function findCarRadius(radius)
local log = {}
for k, v in pairs(getAllVehicles()) do
if doesVehicleExist(v) then
local mx, my, mz = getCharCoordinates(PLAYER_PED)
local cx, cy, cz = getCarCoordinates(v)
local dist = getDistanceBetweenCoords3d(mx, my, mz, cx, cy, cz)
if dist <= radius then
table.insert(log, {v, dist})
end
end
end
if #log > 0 then
table.sort(log, function(a, b) return (a[2] < b[2]) end)
return log[1][1]
end
return nil
end