SkatCh

about markers

Recommended Posts

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 .

Share this post


Link to post

i know that i need to use dxDrawLine3D but how to create it please help .

Share this post


Link to post

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.

Share this post


Link to post

Can any one explane to me how can i use what xXMADEXx gave to me . please

Share this post


Link to post

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 
) 
  

Share this post


Link to post

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)

Share this post


Link to post

Check the code again. Your line must be placed in onClientRender event.

Share this post


Link to post

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.

Share this post


Link to post

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 ) 

Share this post


Link to post

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 
) 

Share this post


Link to post

It's not missing. There should be no "end" on that line.

Share this post


Link to post

ok bro i want to ask you what can i do if i want to draw a rectangle .

Share this post


Link to post

bro i tried my option but i can't draw a rectangle can you help me .

Share this post


Link to post

You're not helping us. What did you try?

Share this post


Link to post

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 .

Share this post


Link to post

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.