• TTT scoreboard rainbow names?
    12 replies, posted
Hello, I saw on my friends old server he had a flashing rainbow name in the TTT scoreboard that would change colors of the rainbow in half a second or so, I was wondering if anyone knew the code to set Steam ID's to do this? I saw on another post of someone asking for the same thing but I was unsure if those codes still worked and which one to use. Thank you very much.
bump
Were you on efhunterzone? If so, that was me with the flashing name lol. But honestly, I couldn't tell you the code. You'd have to ask Efhunter for it. In which case, let me know in this thread if you get it, because I need it for my server. Edit: Also, yes, it is was linked to my SteamID. That's the best way to do it in my opinion.
[lua] local frequency = 0.3 local red = math.sin(frequency*CurTime() + 0) * 127 + 128 local green = math.sin(frequency*CurTime() + 2) * 127 + 128 local blue = math.sin(frequency*CurTime() + 4) * 127 + 128 return Color(red,green,blue) [/lua] Three offset sine waves are what you are looking for. I use this algorithm. Graphed it looks like this. (Courteous of my TI-84) [IMG]http://gyazo.com/6779e994c40934c145165695e80f17b2.png[/IMG]
Or you could use [code]HSVToColor( CurTime() % 360, 1, 1 )[/code]
Ahh okay that info helps alot, thanks guys! Does anyone have a pre-made code where maybe I could just import my SteamID into the file? Not trying to be lazy but I am a bit new to LUA at this point. Thanks alot!
People like to help others with coding not completely make a code for them on these forums.
[QUOTE=Robotboy655;41598782]Or you could use [code]HSVToColor( CurTime() % 360, 1, 1 )[/code][/QUOTE] I never knew that function existed. Thanks for the shortcut.
[QUOTE=kpjVideo;41598854]Ahh okay that info helps alot, thanks guys! Does anyone have a pre-made code where maybe I could just import my SteamID into the file? Not trying to be lazy but I am a bit new to LUA at this point. Thanks alot![/QUOTE] [code]--Rainbow/Flashing name for Kamikazemelon (test) if (self.Player:SteamID() == "STEAM_0:0:7129389") then timer.Create("NameSTEAM_0:0:7129389", 0.1, 0, function () if (IsValid(self.Player)) then self.nick:SetTextColor(Color(math.random(0,255), math.random(0,255), math.random(0,255), 255)) else timer.Destroy("NameSTEAM_0:0:7129389") end end) --[[hook.Add("PlayerDisconnected", "TimerRemoveSTEAM_0:0:7129389", function () if (ply:SteamID() == "STEAM_0:0:7129389" and timer.Exists("NameSTEAM_0:0:7129389")) then timer.Destroy("NameSTEAM_0:0:7129389") end end)]]-- --Rainbow/Flashing name for DeadEd (Test) elseif (self.Player:SteamID() == "STEAM_0:0:27335599") then timer.Create("NameSTEAM_0:0:27335599", 0.1, 0, function () if (IsValid(self.Player)) then self.nick:SetTextColor(Color(math.random(0,255), math.random(0,255), math.random(0,255), 255)) else timer.Destroy("NameSTEAM_0:0:27335599") end end) --[[hook.Add("PlayerDisconnected", "TimerRemoveSTEAM_0:0:27335599", function () if (ply:SteamID() == "STEAM_0:0:27335599" and timer.Exists("NameSTEAM_0:0:27335599")) then timer.Destroy("NameSTEAM_0:0:27335599") end end)]]-- end[/code] Put it between [code]self.voice.DoClick = function() if IsValid(ply) and ply != LocalPlayer() then ply:SetMuted(not ply:IsMuted()) end end[/code] and [code] self:UpdatePlayerData() end[/code] in gamemodes/terrortown/gamemode/vgui/sb_row.lua. Modify the SteamIDs as needed. If you need any more help, I can send the whole file to you through Mediafire. Just figured I'd share it for other people who might want it. Edit: Also, credits to Kamikazemelon. He made it for my TTT server.
Thanks alot H20! Is there a way to change the time to a bit slower?
[QUOTE=H2OJesus;41610794] -snip- [/QUOTE] There are much better ways to [U]switch[/U] steamids and not repeat code as you will have to when you add more people to that code. Considering that the hook TTTScoreboardColorForPlayer is called every time the scoreboard paints there is no need for timers. You can simply return the output of a function and designate it via a table. I made this a long time ago, I am pretty sure it still works. [lua] if (SERVER) then AddCSLuaFile("tg_ttt_scoreboard.lua") end if (CLIENT) then _People = { {"STEAM_0:0:17494584", 1}, {"STEAM_0:0:12123213", Color(255,255,255)}, {"STEAM_0:0:26837081", 2}, {"STEAM_0:1:41746024", Color(0,255,255)}, {"STEAM_0:1:21080880", Color(139,69,19)}, {"STEAM_0:0:25224335", Color(56,0,0)} } local function rainbowFade() // 1 local frequency = 0.3 local red = math.sin(frequency*CurTime() + 0) * 127 + 128 local green = math.sin(frequency*CurTime() + 2) * 127 + 128 local blue = math.sin(frequency*CurTime() + 4) * 127 + 128 return Color(red, green, blue) end local function randomColor() // 2 local red = math.random(255) local green = math.random(255) local blue = math.random(255) return Color(red, green, blue) end local function colorName( ply ) local steam = ply:SteamID() for k,v in pairs( _People ) do if steam == v[1] then local col = v[2] if col == 1 then return rainbowFade() elseif col == 2 then return randomColor() else return col end end end end hook.Add("TTTScoreboardColorForPlayer", "Color Dem Bitches", colorName) end [/lua]
[QUOTE=Robotboy655;41598782]Or you could use [code]HSVToColor( CurTime() % 360, 1, 1 )[/code][/QUOTE] Use RealTime instead of CurTime. CurTime is synchronized with the server and will result in choppy animations in the case of lag.
[QUOTE=kpjVideo;41614228]Thanks alot H20! Is there a way to change the time to a bit slower?[/QUOTE] Yes, but I wouldn't know how. I'll talk to Kamakazie and see if he can cook something up real quick. It's no problem my man.
Sorry, you need to Log In to post a reply to this thread.