Jump to content

Help - Marker color for teams


manve1

Recommended Posts

I am trying to make a script which would change the markers color into the teams color:

function mark( thePlayer ) 
local r, g, b, a = getTeamColor( getPlayerTeam(thePlayer) == "LS" ) 
setMarkerColor( topdeck, r, g, b, a ) 
end 
) 
addEventHandler('onMarkerHit', topdeck, mark) 

Link to comment
addEventHandler( "onMarkerHit", topdeck, 
    function( player ) 
        local nR, nG, nB, nA = getTeamColor( getTeamFromName( "LS" ) ) 
        if ( nR and nG and nB and nA ) then 
            setMarkerColor( source, nR, nG, nB, nA ); 
        end 
    end 
) 

Link to comment
addEventHandler("onMarkerHit",topdeck, 
    function( thePlayer ) 
        if ( getElementType(thePlayer) == "player" ) then 
            local nR, nG, nB = getTeamColor( getPlayerTeam( thePlayer ) ) 
            setMarkerColor( source, nR, nG, nB ) 
        end 
    end 
) 

btw, there's no 'alpha' return in getTeamColor function

Link to comment

@Teteomar: You forgot to fill the alpha argument:

addEventHandler("onMarkerHit",topdeck, 
    function( thePlayer ) 
        if ( getElementType(thePlayer) == "player" ) then 
            local nR, nG, nB = getTeamColor( getPlayerTeam( thePlayer ) ) 
            setMarkerColor( source, nR, nG, nB, 255 ) 
        end 
    end 
) 

Link to comment
@Teteomar: You forgot to fill the alpha argument:
addEventHandler("onMarkerHit",topdeck, 
    function( thePlayer ) 
        if ( getElementType(thePlayer) == "player" ) then 
            local nR, nG, nB = getTeamColor( getPlayerTeam( thePlayer ) ) 
            setMarkerColor( source, nR, nG, nB, 255 ) 
        end 
    end 
) 

getTeamColor 

Returns 3 integers representing the red, green, and blue color components of the team if it's valid, false otherwise.

Link to comment

I already know that, but if you check the setMarkerColor required arguments, you can see that alpha is required.

Required Arguments

theMarker: The marker that you wish to set the color of.

r: The amount of red in the final color (0 to 255).

g: The amount of green in the final color (0 to 255).

b: The amount of blue in the final color (0 to 255).

a: The amount of alpha in the final color (0 to 255).

Link to comment
addEventHandler ( "onMarkerHit", topdeck, 
    function ( thePlayer ) 
        if ( thePlayer and getElementType ( thePlayer ) == "player" ) then 
            local nR, nG, nB = getTeamColor ( getPlayerTeam ( thePlayer ) ) 
            setMarkerColor ( source, nR, nG, nB, 255 ) 
        end 
    end 
) 

Link to comment

CLIENT:

local bar = guiCreateProgressBar( 0.05, 0.75, 0.9, 0.05, true, computerGUI ) 
  
capturing = setTimer( 
function() 
guiProgressBarSetProgress(bar, guiProgressBarGetProgress(bar) + 5) 
if ( guiProgressBarGetProgress(bar) == 100 ) then 
outputChatBox('#FF0000[iNFO]: #FFFFFFHacking finnished.', 255, 255, 255, true) 
    triggerServerEvent('changecolor1topdeck', localPlayer) 
    killTimer( capturing ) 
    if isElement( bar ) and (bar) then 
    destroyElement( bar ) 
    end 
    end 
end, 1000, 0 
) 

SERVER:

addEvent('changecolor1topdeck', true) 
addEventHandler('changecolor1topdeck', getRootElement( ), 
function( thePlayer ) 
    if ( thePlayer and getElementType ( thePlayer ) == "player" ) then 
        local nR, nG, nB = getTeamColor( getPlayerTeam( thePlayer ) ) 
        setMarkerColor( source, nR, nG, nB, 100 ) 
    end 
end 
) 

Link to comment
addEvent('changecolor1topdeck', true) 
addEventHandler('changecolor1topdeck', getRootElement( ), 
function( ) 
    if ( getElementType ( source ) == "player" ) then 
        local nR, nG, nB = getTeamColor( getPlayerTeam( source ) ) 
        setMarkerColor( topdeck, nR, nG, nB, 100 ) 
    end 
end 
) 

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...