SkatCh Posted June 28, 2014 Posted June 28, 2014 hi guys please i have a question how can i change the marker type . i know all markers type from wiki but i mean custom marker . thank you .
SkatCh Posted June 29, 2014 Author Posted June 29, 2014 i know that i need to use dxDrawLine3D but how to create it please help .
xXMADEXx Posted June 29, 2014 Posted June 29, 2014 You can use the following function (credits to 50p for creating it) function dxDrawCircle3D( x, y, z, radius, segments, color, width ) segments = segments or 16; -- circle is divided into segments -> higher number = smoother circle = more calculations color = color or tocolor( 255, 255, 0 ); width = width or 1; local segAngle = 360 / segments; local fX, fY, tX, tY; -- drawing line: from - to for i = 1, segments do fX = x + math.cos( math.rad( segAngle * i ) ) * radius; fY = y + math.sin( math.rad( segAngle * i ) ) * radius; tX = x + math.cos( math.rad( segAngle * (i+1) ) ) * radius; tY = y + math.sin( math.rad( segAngle * (i+1) ) ) * radius; dxDrawLine3D( fX, fY, z, tX, tY, z, color, width ); end end Use a loop on the client side to get all of the markers, set their alpha to 0 and then call the function.
SkatCh Posted August 3, 2014 Author Posted August 3, 2014 thx bro for ur help but i'm sorry i don't undrestand how
SkatCh Posted August 3, 2014 Author Posted August 3, 2014 Can any one explane to me how can i use what xXMADEXx gave to me . please
50p Posted August 3, 2014 Posted August 3, 2014 Simply copy the function to your file. Then loop through all the markers, make them invisible (alpha=0) and draw the circle in the same spot. addEventHandler( "onClientRender", root, function( ) for _, marker in pairs( getElementsByType("marker") ) do if getMarkerType( marker ) == "cylinder" then setElementAlpha( marker, 0 ); -- make the marker invisible local x,y,z = getElementPosition( marker ); local radius = getMarkerSize( marker ); local color = tocolor( getMarkerColor( marker ) ); dxDrawCircle3D( x, y, z, radius, 24, color ); end end end )
SkatCh Posted August 3, 2014 Author Posted August 3, 2014 thx bro for help i changed all markers alpha to 0 but i can't see the dxDrawcircle. can you tell me how to create it is this right : dxDrawCircle3D(1631.2060546875,1850.658203125,10.8203125,1.5,24,tocolor( 255, 255, 0 ),2)
50p Posted August 3, 2014 Posted August 3, 2014 Check the code again. Your line must be placed in onClientRender event.
SkatCh Posted August 4, 2014 Author Posted August 4, 2014 thx 50p for your time , i fixed it and now i can see it but just stay 3 second . Edit : Thank you so much bro i fixed it . topic can be locked.
TAPL Posted August 4, 2014 Posted August 4, 2014 The script already get the positions of all markers in the server and draw the line by itself you don't need to get it manually. There's only one problem with alpha within 50p code. local color = tocolor( getMarkerColor( marker ) ) Change to: local r, g, b = getMarkerColor( marker ) local color = tocolor( r, g, b, 255 )
SkatCh Posted August 4, 2014 Author Posted August 4, 2014 no it's working fine i already asked to close the topic , just i want to add something ; 50p you must add this : addEventHandler( "onClientRender", root, function( ) for _, marker in pairs( getElementsByType("marker") ) do if getMarkerType( marker ) == "cylinder" then setElementAlpha( marker, 0 ); -- make the marker invisible local x,y,z = getElementPosition( marker ); local radius = getMarkerSize( marker ); local color = tocolor( getMarkerColor( marker ) ); dxDrawCircle3D( x, y, z, radius, 24, color ); end end end end <---------------------------------- missing )
50p Posted August 4, 2014 Posted August 4, 2014 It's not missing. There should be no "end" on that line.
SkatCh Posted August 4, 2014 Author Posted August 4, 2014 ok bro i want to ask you what can i do if i want to draw a rectangle .
50p Posted August 4, 2014 Posted August 4, 2014 dxDrawRectangle. If you want to draw a rectangle in 3D then use dxDrawLine3D and make it face along +Z. Just check its parameters.
SkatCh Posted August 5, 2014 Author Posted August 5, 2014 bro i tried my option but i can't draw a rectangle can you help me .
SkatCh Posted August 5, 2014 Author Posted August 5, 2014 i'm sorry bro if i waste your time , i tried the same script this : function dxDrawCircle3D( x, y, z, radius, segments, color, width ) segments = segments or 16; -- circle is divided into segments -> higher number = smoother circle = more calculations color = color or tocolor( 255, 255, 0 ); width = width or 1; local segAngle = 360 / segments; local fX, fY, tX, tY; -- drawing line: from - to for i = 1, segments do fX = x + math.cos( math.rad( segAngle * i ) ) * radius; fY = y + math.sin( math.rad( segAngle * i ) ) * radius; tX = x + math.cos( math.rad( segAngle * (i+1) ) ) * radius; tY = y + math.sin( math.rad( segAngle * (i+1) ) ) * radius; dxDrawLine3D( fX, fY, z, tX, tY, z, color, width ); end end i changed the seagnle etc but i got an other form not a rectangle , i think it's wrong . because i don't undrestand your last answer .
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now