ServersYour serverFor creatorsForumFAQDocumentationSecurity
Download the launcher
  1. Documentation
  2. Shared functions
  3. getVehicleRoute

Function

getVehicleRoute

Server and clientWorldTrilogy Hub only

Finds a car route along the game's roads between two points, respecting one-way streets and highway lanes. On the server it works immediately, with no players nearby. The client asks the server, so it only works inside async and waits up to 3 s.

Syntax

table, float getVehicleRoute(float x1, float y1, float z1, float x2, float y2, float z2 [, table options = nil])

Arguments

x1float
Start X.
y1float
Start Y.
z1float
Start Z.
x2float
Destination X.
y2float
Destination Y.
z2float
Destination Z.
optionstable, optional = nil
avoidHighways, boat (boat route), emergency (emergency-only roads), ignoreOneWay.

Returns

A list of points { {x, y, z}, ... } and the length in metres; false and a reason if there is no road.

Example

local points, length = getVehicleRoute(2495, -1667, 13, 1544, -1675, 13)
if points then print(#points .. " punktów, " .. math.floor(length) .. " m") end

See also