dxDrawPrimitive | Multi Theft Auto: Wiki Skip to content

dxDrawPrimitive

Client-side
Server-side
Shared
Needs checking

This function was partially migrated from the old wiki. Please review manually:

  • Missing section: Allowed types
  • Missing section: Vertices format

This page is incomplete! Help wanted!

Please finish this page using the corresponding Old Wiki article.
Go to Contribution guidelines for more information.


This function draws a 2D primitive shape across the screen - rendered for one frame. This should be used in conjunction with onClientRender in order to display continuously.

Syntax

dxDrawPrimitive ( )

Code Examples

client

This is a small example that creates trianglefan primitive with vertices in places that user clicks. It assigns every vertex random color.

local vertices = {}
function onClick(btn, state, x, y)
if btn ~= "left" then return end
if state ~= "up" then return end
local vertex = {x, y, tocolor(math.random(255), math.random(255), math.random(255))}
table.insert(vertices, vertex)
end
addEventHandler("onClientClick", root, onClick)
function draw()
dxDrawPrimitive("trianglefan", true, unpack(vertices))
end
addEventHandler("onClientPreRender", root, draw)