ZeyadGTX Posted June 6, 2014 Share Posted June 6, 2014 i use this Script which makes you have the team Color like if Team color is Yellow you get the same Color when you are in that Team, but i had a Problem why the player must Reconnect to take the team color why can't he get the teamcolor without reconnect ? Or he must Logout Then Login , I hate that every time i must /restart play to get the player team color 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 = {} local randomColor = { [1] = {255,255,255}, [2] = {255,0,255}, [3] = {0,255,0} } 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("YOU HAVE NO TEAM", 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
-.Paradox.- Posted June 6, 2014 Share Posted June 6, 2014 Spider, You will never understand, For me (no offence) Maybe it's somebody else script, Anyway Line 20 change 'onPlayerLogin' and create an event name it 'onPlayerTeamChange' and use it. Link to comment
cheez3d Posted June 6, 2014 Share Posted June 6, 2014 (edited) addEvent("onPlayerTeamChange"); local _setPlayerTeam = setPlayerTeam; setPlayerTeam = function(player,team) local PreviousTeam = getPlayerTeam(player); local Result = _setPlayerTeam(player,team); if Result then triggerEvent("onPlayerTeamChange",player,PreviousTeam,team); end; return Result; end; addEventHandler("onPlayerTeamChange",root,function(_,team) local Color = getTeamColorName(team); Color = Color and Color or {255,255,255}; local Name = getPlayerName(source); Name = ("#%.2X%.2X%.2X"):format(Color[1],Color[2],Color[3])..Name:gsub("#%x%x%x%x%x%x",""); setPlayerName(source,Name); end); Edited June 8, 2014 by Guest Link to comment
ZeyadGTX Posted June 6, 2014 Author Share Posted June 6, 2014 its n't working i removed Line 20 and now i don't even have team color, and no errors in Debug Script 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 = {} local randomColor = { [1] = {255,255,255}, [2] = {255,0,255}, [3] = {0,255,0} } addEventHandler("onPlayerTeamChange", 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("YOU HAVE NO TEAM", 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