Skip to content

A3D_GetRouteProgress

imshooter edited this page Oct 23, 2026 · 2 revisions

Find where a point is along a route: the distance left, the distance from the route and the next turn.

The point goes to the nearest part of the route, and where the route passes a place twice, to the part nearer where the last call put it. A distance from the route that keeps growing means the player took another way, and a new route from where they are brings them back.

native bool:A3D_GetRouteProgress(
    Route:routeid,
    Float:x,
    Float:y,
    Float:z,
    &Float:remaining,
    &Float:away = 0.0,
    &next = 0,
    &A3D_TURN:turn = A3D_TURN_NONE,
    &Float:turnDistance = 0.0
);

Parameters

Parameter Description Default
Route:routeid Route to follow.
Float:x Point on the X axis.
Float:y Point on the Y axis.
Float:z Point on the Z axis.
&Float:remaining Distance left to the end of the route, in metres.
&Float:away Distance from the point to the route. 0.0
&next Index of the next point of the route. 0
&A3D_TURN:turn The next turn, or A3D_TURN_NONE when none is left. A3D_TURN_NONE
&Float:turnDistance Distance to the next turn, or to the end when none is left. 0.0

Returns

  • true when the route exists.
  • false when it does not.

Remarks

This is what a GPS asks every second or so. remaining and the next turn give what the player reads, and a growing away tells that they took another way. A3D_ShowRouteForPlayer does the same for the route it shows, on its own, and calls A3D_OnRouteLeft and A3D_OnRouteArrived.

The search starts around the part of the route the last call found, so it costs a few microseconds whatever the length of the route.

Example

Writes the next turn in a text draw of the player.

stock UpdateDirections(playerid, Route:routeid, PlayerText:text) {
    new
        Float:x,
        Float:y,
        Float:z,
        Float:remaining,
        Float:away,
        next,
        A3D_TURN:turn,
        Float:turnDistance,
        string[64]
    ;

    GetPlayerPos(playerid, x, y, z);
    A3D_GetRouteProgress(routeid, x, y, z, remaining, away, next, turn, turnDistance);

    if (turn == A3D_TURN_NONE) {
        format(string, sizeof (string), "Arrive in %i m", floatround(remaining));
    } else {
        format(string, sizeof (string), "Turn in %i m, %.1f km to go", floatround(turnDistance), remaining / 1000.0);
    }

    PlayerTextDrawSetString(playerid, text, string);
}

Related

  • A3D_GetRouteTurn: Read a turn of a route, at a junction where more than two ways meet.
  • A3D_ShowRouteForPlayer: Show a route on the radar and the map of a player as a line, which moves on as they go.
  • A3D_OnRouteLeft: A player strayed from the route shown to them.
  • A3D_OnRouteArrived: A player reached the end of the route shown to them. The route stays on the map until it is hidden or destroyed.

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