- Documentation
- Client functions
- getPlayerWaypointRoute
Function
getPlayerWaypointRoute
Returns the game's GPS route to the waypoint, the line shown on the radar, as a list of points and a length in metres. The game computes a road route only while the player is in a vehicle.
Syntax
table getPlayerWaypointRoute([bool withZ = false])Arguments
withZbool, optional = falsetrue= every point also getsz(ground height).
Returns
points, length: a table of {x = , y = [, z = ]} and the length in metres; false if there is no route.
Example
The GPS route drawn in the world.
local route = false
addEventHandler("onClientWaypointRouteUpdate", localPlayer, function(hasRoute)
route = hasRoute and getPlayerWaypointRoute(true) or false
end)
addEventHandler("onClientRender", root, function()
if not route then return end
for i = 2, #route do
local a, b = route[i - 1], route[i]
dxDrawLine3D(a.x, a.y, a.z + 0.5, b.x, b.y, b.z + 0.5, tocolor(80, 160, 255), 6)
end
end)
Notes
There may be gaps between parts of the route - then draw lines only between neighbouring points, as in the example.
See also
onClientWaypointRouteUpdateThe game recomputed the GPS route to the waypoint (the line on the radar), or the route disappeared.getPlayerWaypointRoutegives the route's points.getPlayerWaypointReturns the player's GPS waypoint, the target they marked on the map or a script set. On the server it is the last point confirmed by the player's game.setPlayerWaypointSets the game's GPS waypoint for a player: a target on the radar and map, and a road route while in a vehicle. The game confirms it withonPlayerWaypointSet.