getNearestVehicle
Finds the nearest vehicle within the specified distance.
Parameters:
coords
(vector3, optional): The coordinates to search from. Defaults to player's current position.distance
(number, optional): Maximum search distance in units. Defaults to 10.0.
Returns:
vehicle
(entity): The nearest vehicle entity, or'no nearby vehicle'
if none founddistance
(number): Distance to the nearest vehicle, or'no nearby vehicle'
if none found
Example:
local nearestVehicle, vehicleDistance = ps.getNearestVehicle()
if nearestVehicle ~= 'no nearby vehicle' then
local model = GetEntityModel(nearestVehicle)
print("Found vehicle model: " .. model)
end
Last updated