DxDrawLine3D: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 5: Line 5:
==Syntax==
==Syntax==
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
dxDrawLine3D ( x1, y1, z1, x2, y2, z2, tocolor ( r, g, b, a ), width )
bool dxDrawLine3D ( float startX, float startY, float startZ, float endX, float endY, float endZ, int color, int width )
</syntaxhighlight>
</syntaxhighlight>


===Required Arguments===  
===Required Arguments===  
 
'''startX:''' The start X position of the 3D line
'''startY:''' The start Y position of the 3D line
'''startZ:''' The start Z position of the 3D line
'''endX:''' The end X position of the 3D line
'''endY:''' The end Y position of the 3D line
'''endZ:''' The end Z position of the 3D line
'''color:''' An integer of the hex color, produced using [[tocolor]].
'''width:''' The width/thickness of the line


===Returns===
===Returns===
 
Returns a ''true'' if the operation was successful, ''false'' otherwise.


==Example==  
==Example==  

Revision as of 18:50, 2 March 2008

Draws a line between two points in the 3D world.

Syntax

bool dxDrawLine3D ( float startX, float startY, float startZ, float endX, float endY, float endZ, int color, int width )

Required Arguments

startX: The start X position of the 3D line startY: The start Y position of the 3D line startZ: The start Z position of the 3D line endX: The end X position of the 3D line endY: The end Y position of the 3D line endZ: The end Z position of the 3D line color: An integer of the hex color, produced using tocolor. width: The width/thickness of the line

Returns

Returns a true if the operation was successful, false otherwise.

Example

This is a small example of creating 3D Line / "Rope" between vehicle and player.

testVehicle = createVehicle ( 411, 0, 0, 5 ) -- Create our test vehicle.

function createLine ( )
	x1, y1, z1 = getElementPosition ( testVehicle )                       -- Get test vehicles position.
	x2, y2, z2 = getElementPosition ( getLocalPlayer ())                  -- Get local players position.
	dxDrawLine3D ( x1, y1, z1, x2, y2, z2, tocolor ( 0, 255, 0, 230 ), 2) -- Create 3D Line between test vehicle and local player.
addEventHandler("onClientRender",getRootElement(), createLine)                -- onClientRender keeps the 3D Line visible.
end
addCommandHandler("test", createLine)

See Also