Jump to content

about markers


SkatCh

Recommended Posts

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.

Link to comment
  • 1 month later...

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 
) 
  

Link to comment
  • Other Languages Moderators

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 ) 

Link to comment

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 
) 

Link to comment

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 .

Link to comment

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.

×
×
  • Create New...