Skip to content

A3D_GetNearestPathPoint

imshooter edited this page Oct 23, 2026 · 1 revision

Find the nearest point of a path a route can use, and the direction of the path there.

On a one way street the angle points the way the traffic goes, which places a vehicle on the road facing the right way.

native bool:A3D_GetNearestPathPoint(
    Float:x,
    Float:y,
    Float:z,
    &Float:pathX,
    &Float:pathY,
    &Float:pathZ,
    &Float:angle = 0.0,
    A3D_ROUTE:type = A3D_ROUTE_FASTEST,
    Float:reach = 100.0
);

Parameters

Parameter Description Default
Float:x Point on the X axis.
Float:y Point on the Y axis.
Float:z Point on the Z axis.
&Float:pathX Point of the path on the X axis.
&Float:pathY Point of the path on the Y axis.
&Float:pathZ Point of the path on the Z axis.
&Float:angle Direction of the path, as SetVehicleZAngle takes it. 0.0
A3D_ROUTE:type Which paths count. A3D_ROUTE_FASTEST
Float:reach How far to look, in metres. 100.0

Returns

  • true when a path is within reach.
  • false when none is.

Remarks

The point lies on the line of the path, which runs down the middle of a road. On a one way street, angle points the way the traffic goes, and on a two way road it points one of the two ways. A3D_ROUTE_TRAFFIC finds only the roads the traffic of the game drives, which keeps a spawned vehicle out of alleys and car parks.

Example

Puts a vehicle on the nearest road, facing the traffic.

stock SpawnOnRoad(modelid, Float:x, Float:y, Float:z) {
    new
        Float:roadX,
        Float:roadY,
        Float:roadZ,
        Float:angle
    ;

    if (!A3D_GetNearestPathPoint(x, y, z, roadX, roadY, roadZ, angle, A3D_ROUTE_TRAFFIC)) {
        return INVALID_VEHICLE_ID;
    }

    return CreateVehicle(modelid, roadX, roadY, roadZ + 1.0, angle, -1, -1, 600);
}

Related

  • A3D_FindRoute: Find the best route between two points along the paths of the game.
  • A3D_GetNearestWalkPoint: Find the nearest point of the navigation mesh, where a pedestrian can stand.

Home

Guides

Reference

Functions

Creating objects
Motion
Placement
Behaviour
Display and data
Rays
Shapes
Players, vehicles and actors
Map probes
Screen
Map objects
Water
Models and surfaces
Rotations and offsets
Vehicles
Routes
Route display
Walking
Callbacks

Clone this wiki locally