M MY Multiplayer: Wiki
Side
Kind

getRoadDensity

Client

Measures how much road there is around a point: the lanes times the length of the car links starting within 80 m of it, scaled down.

float getRoadDensity(float x, y)

Parameters

NameTypeDescription
x, yfloatThe point on the map.

Returns

The density, 0 when there are no loaded roads nearby.

Example

local position = getElementPosition(localPlayer)
if getRoadDensity(position.x, position.y) < 0.1 then
    outputDebugString("you are far from any road")
end
NoteOnly nodes in loaded path areas count: those near the player, or requested with requestPathNodesInArea.

See also