AlvarO Posted January 3, 2016 Posted January 3, 2016 Hey, so I was wondering how to pass a r,g,b colorcode to hex one, and if it is possible, how to do it with a raimbow colorcode? Thanks. MTA:SA SPANISH DEATHMATCH PLAYER
Revolt Posted January 3, 2016 Posted January 3, 2016 https://wiki.multitheftauto.com/wiki/RGBToHex Rainbow color code example: outputChatBox("#FFFF00T#FFD700E#FFA500S#FF8C00T#FF45001", root, 255, 255, 255, true) It will output: TEST1 Need a scripter? Feel free to contact me for inexpensive high-quality service! Skype username: friedonibot
AlvarO Posted January 3, 2016 Author Posted January 3, 2016 (edited) Thanks! but not that raimbow, I wanted a rainbow like the car colors ones. Edited January 3, 2016 by Guest MTA:SA SPANISH DEATHMATCH PLAYER
Revolt Posted January 3, 2016 Posted January 3, 2016 Hmm, I'm not sure what do you mean by 'raimbow like the car colors ones'. Need a scripter? Feel free to contact me for inexpensive high-quality service! Skype username: friedonibot
AlvarO Posted January 3, 2016 Author Posted January 3, 2016 Like a color, and that color goes changing from white to black infinite times. MTA:SA SPANISH DEATHMATCH PLAYER
Syntrax# Posted January 3, 2016 Posted January 3, 2016 Like a color, and that color goes changing from white to black infinite times. use this code it's clientside setTimer ( function() if isPedInVehicle( getLocalPlayer( )) then local uVehicle = getPedOccupiedVehicle( getLocalPlayer( ) ) if uVehicle then local r, g, b = math.random( 255 ), math.random( 255 ), math.random( 255 ) setVehicleColor( uVehicle, r, g, b ) end end end, 5000, 1 ) Nothing is impossible when you acquire the knowledge
Addlibs Posted January 3, 2016 Posted January 3, 2016 Like a color, and that color goes changing from white to black infinite times. That is not a colour but a sequence of different colours. Previously known as MrTasty.
Revolt Posted January 3, 2016 Posted January 3, 2016 (edited) local color = {[0] = 0, [1] = 100, [2] = 200} local increment = 5 function changeColor() for k in ipairs(color) do color[k] = color[k] + increment if (color[k] > 255) then color[k] = -255 end end setVehicleColor(theVehicle, math.abs(color[0]), math.abs(color[1]), math.abs(color[2]), math.abs(color[0]), math.abs(color[1]), math.abs(color[2])) end local timer = setTimer(changeColor, 50, 0) Maybe something like this would work for some kind of rainbow? If you really wish for a rainbow color, then you should define the desired colors and interpolate between them infinite times... Edited January 3, 2016 by Guest Need a scripter? Feel free to contact me for inexpensive high-quality service! Skype username: friedonibot
Addlibs Posted January 3, 2016 Posted January 3, 2016 I'd do it onClientRender with math or interpolation (getEasingValue or interpolateBetween). Previously known as MrTasty.
Revolt Posted January 3, 2016 Posted January 3, 2016 onClientRender may be better (although it might cause lags, since we don't know how much impact on the CPU will the setVehicleColor ( .. ) cause. Thumbs up for the interpolateBetween (..) method, though. Need a scripter? Feel free to contact me for inexpensive high-quality service! Skype username: friedonibot
AlvarO Posted January 3, 2016 Author Posted January 3, 2016 And for a team? Also thanks, the code for vehicle works perfectly MTA:SA SPANISH DEATHMATCH PLAYER
Revolt Posted January 3, 2016 Posted January 3, 2016 And for a team? Also thanks, the code for vehicle works perfectly If you're referring for applying rainbow color to teams, then just use setTeamColor (..) instead of setVehicleColor (..) with the same arguments for R, G and B. Need a scripter? Feel free to contact me for inexpensive high-quality service! Skype username: friedonibot
AlvarO Posted January 4, 2016 Author Posted January 4, 2016 And how it with work in an auto team? CODE: Names={} Tags={} Colors={} local names ={"Empire Street Riders"} local tags ={"EsR"} local colors ={"#256f5c"} function loadTeams() for i,name in pairs(names) do Names[i]=name end for i,tag in pairs(tags) do Tags[i]=tag end for i,color in pairs(colors) do Colors[i] = color end end addEventHandler("onResourceStart",root,loadTeams) function moveOnStart() for i,player in pairs(getElementsByType("player")) do check(player) end end addEventHandler("onResourceStart",root,moveOnStart) function check (player) setPlayerTeam(player,nil) for i,tag in pairs(tags) do if string.find(getPlayerName(player),tag) then local name = Names[i] local color = Colors[i] if not getTeamFromName(name) then createTeam(name,getColorFromString(color)) end local team = getTeamFromName(name) setPlayerTeam(player,team) end end end function remove() for t,teams in pairs(names) do local team = getTeamFromName(teams) if team then if countPlayersInTeam ( team )==0 then destroyElement(team) end end end end function nick(old,new) setTimer(check,1000,1,source) setTimer(remove,1500,1) end addEventHandler("onPlayerChangeNick",root,nick) function join() setTimer(check,4000,1,source) end addEventHandler("onPlayerJoin",root,join) function quit(player) setTimer(remove,1000,1) end addEventHandler("onPlayerQuit",root,quit) MTA:SA SPANISH DEATHMATCH PLAYER
AlvarO Posted January 4, 2016 Author Posted January 4, 2016 Any idea? MTA:SA SPANISH DEATHMATCH PLAYER
aka Blue Posted January 4, 2016 Posted January 4, 2016 Try this function friend: 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
Addlibs Posted January 5, 2016 Posted January 5, 2016 He's not looking for RGB to Hex anymore — He wants to make colours smoothly change from one to another on team color (or at least that's what I understood. Read the full topic. Previously known as MrTasty.
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