ServersYour serverFor creatorsForumFAQDocumentationSecurity
Download the launcher
  1. Documentation
  2. Client functions
  3. dxDrawLine3D

Function

dxDrawLine3D

Draws a line between two world points: projects them onto the screen and joins them. It only draws when both ends are on screen and is not hidden by buildings.

Syntax

bool dxDrawLine3D(float startX, startY, startZ, float endX, endY, endZ [, int color = tocolor(255, 255, 255), float width = 1, bool postGUI = false, bool smooth = false])

Arguments

startX, startY, startZfloat
Start in the world.
endX, endY, endZfloat
End in the world.
colorint, optional = tocolor(255, 255, 255)
Colour.
widthfloat, optional = 1
Thickness in pixels.
postGUIbool, optional = false
Above GUI.Different default in MTA:SA: bool/string stage = "postfx"
smoothbool, optional = false
true = a smooth line: soft edges without jaggies and rounded ends, so consecutive segments (e.g. a path along the ground) join without gaps.Not in MTA:SA

Differences from MTA:SA

  • Arguments in a different colour differ from MTA:SA.

In MTA:SA

dxDrawLine3D(float startX, float startY, float startZ, float endX, float endY, float endZ, int color = 0xFFFFFFFF, float width = 1.0, bool/string stage = "postfx")

Returns

true if drawn.

Example

addEventHandler("onClientRender", root, function()
    local x, y, z = getElementPosition(localPlayer)
    dxDrawLine3D(x, y, z, x, y, z + 5, tocolor(255, 0, 0), 3)
end)

Notes

A segment with one end behind the camera or off screen is clipped (to a plane 0.6 m in front of the camera and to the screen edges), so the visible part is drawn instead of nothing.

See also