Repository navigation
A3D_GetRouteProgress
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
);| 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 |
-
truewhen the route exists. -
falsewhen it does not.
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.
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);
}- 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.
3DAndreas 0.7.1 · Repository · Releases · MIT License
Guides
- Installation
- Configuration
- Physics objects
- Model settings
- World queries
- The screen
- Routes
- Navigation mesh
- Map database
- Coming from ColAndreas
- Performance
Reference
Functions