Bilal135 Posted July 10, 2014 Share Posted July 10, 2014 Hey guys, I have a script, when we add some player in a team, he needs to reconnect to get the team color. Can anybody fix it for me? so the player won't need to reconnect. function RGBToHex(red, green, blue, alpha) if((red < 0 or red > 255 or green < 0 or green > 255 or blue < 0 or blue > 255) or (alpha and (alpha < 0 or alpha > 255))) then return nil end if(alpha) then return string.format("#%.2X%.2X%.2X%.2X", red,green,blue,alpha) else return string.format("#%.2X%.2X%.2X", red,green,blue) end end local blip = {} addEventHandler("onPlayerLogin", root, function () if not isElement(blip[source]) then blip[source] = createBlipAttachedTo(source) end local theTeam = getPlayerTeam(source) if theTeam then local r, g, b = getTeamColor(theTeam) setPlayerNametagColor(source, r, g, b) setBlipColor(blip[source], r, g, b, 255) setPlayerName(source,getPlayerName(source):gsub('#%x%x%x%x%x%x',RGBToHex(r,g,b))) else outputChatBox("", source) rr,gg,bb = unpack(randomColor[math.random(#randomColor)]) setBlipColor(blip[source], rr,gg,bb,255) setPlayerName(source,getPlayerName(source):gsub('#%x%x%x%x%x%x',RGBToHex(rr,gg,bb))) setPlayerNametagColor(source, rr,gg,bb) end end ) addEventHandler("onPlayerQuit", root, function() if isElement(blip[source]) then destroyElement(blip[source]) end end ) Link to comment
Max+ Posted July 11, 2014 Share Posted July 11, 2014 Try This , function RGBToHex(red, green, blue, alpha) if((red < 0 or red > 255 or green < 0 or green > 255 or blue < 0 or blue > 255) or (alpha and (alpha < 0 or alpha > 255))) then return nil end if(alpha) then return string.format("#%.2X%.2X%.2X%.2X", red,green,blue,alpha) else return string.format("#%.2X%.2X%.2X", red,green,blue) end end local blip = {} addEventHandler("onPlayerJoin", root, function () if not isElement(blip[source]) then blip[source] = createBlipAttachedTo(source) end local theTeam = getPlayerTeam(source) if theTeam then local r, g, b = getTeamColor(theTeam) setPlayerNametagColor(source, r, g, b) setBlipColor(blip[source], r, g, b, 255) setPlayerName(source,getPlayerName(source):gsub('#%x%x%x%x%x%x',RGBToHex(r,g,b))) else outputChatBox("", source) rr,gg,bb = unpack(randomColor[math.random(#randomColor)]) setBlipColor(blip[source], rr,gg,bb,255) setPlayerName(source,getPlayerName(source):gsub('#%x%x%x%x%x%x',RGBToHex(rr,gg,bb))) setPlayerNametagColor(source, rr,gg,bb) end end ) addEventHandler("onPlayerQuit", root, function() if isElement(blip[source]) then destroyElement(blip[source]) end end ) Link to comment
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