vehicles.getDistanceFromPoint
Measures the straight-line distance from a vehicle’s current position to a point in the world.
Signature
Section titled “Signature”vehicles.getDistanceFromPoint(id: number, point: Vector3): number | undefinedParameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
id |
number |
The vehicle’s network ID. |
point |
Vector3 |
The point, in world coordinates. |
Returns
Section titled “Returns”The distance in metres, or undefined for an unknown vehicle or a point that is not three finite numbers.
Example
Section titled “Example”import { server, vehicles } from "nativemp";
const garage = [2495, -1680, 13.3] as const;
server.on("playerEnteredVehicle", ({ player, vehicleId }) => { const distance = vehicles.getDistanceFromPoint(vehicleId, garage); if (distance !== undefined && distance < 10) server.log(`${player.name} took a car from the garage`);});Related
Section titled “Related”vehicles.getById: the vehicle’s position and more