manve1 Posted December 6, 2012 Posted December 6, 2012 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)
Anderl Posted December 6, 2012 Posted December 6, 2012 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 )
Tete omar Posted December 7, 2012 Posted December 7, 2012 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
Castillo Posted December 7, 2012 Posted December 7, 2012 @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 )
Tete omar Posted December 7, 2012 Posted December 7, 2012 @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.
Castillo Posted December 7, 2012 Posted December 7, 2012 I already know that, but if you check the setMarkerColor required arguments, you can see that alpha is required. Required ArgumentstheMarker: 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).
Tete omar Posted December 7, 2012 Posted December 7, 2012 oh sorry , i thought you were talking about getTeamColor , sorry i forgot that
manve1 Posted December 7, 2012 Author Posted December 7, 2012 Edit ==> i get error at getElementByType [Expected element at argument 1, got nil]
Tete omar Posted December 7, 2012 Posted December 7, 2012 That's because it's not a player element who hit the marker?
manve1 Posted December 7, 2012 Author Posted December 7, 2012 That's because it's not a player element who hit the marker? It is a player, because I hit it.
Castillo Posted December 7, 2012 Posted December 7, 2012 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 )
manve1 Posted December 7, 2012 Author Posted December 7, 2012 no error now, but marker doesn't change color
manve1 Posted December 7, 2012 Author Posted December 7, 2012 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 )
Castillo Posted December 7, 2012 Posted December 7, 2012 So, here we are fixing the script and it turns out it was a completely different thing, 'source' in your script is the player element, and 'thePlayer' is obviously nil.
manve1 Posted December 7, 2012 Author Posted December 7, 2012 How can i fix it? After all, i changed source to topdeck, got no error, but it still is white, not the team colored
Castillo Posted December 7, 2012 Posted December 7, 2012 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 )
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