Simple timer to make text flash.

I know there is a way to make this type of text flash with different colors but I just keep missing it. I would like this to flash between colors, tried putting a timer on it and making it change but didn’t go so well. Any ideas?

[lua]
if ply:IsUserGroup(“superadmin”) then
self.cols[5]:SetText(“Server Owner”)
self.cols[5]:SetTextColor(Color( 178,34,34, 255 ))
end
[/lua]

[lua]self.cols[5].Think = function(me)
me:SetTextColor(Color(178, 34, 34, math.abs(math.sin(RealTime() * math.pi * 2)) * 255))
end[/lua]

That would flash the transparency. I’m sure you can figure out how to do colors.

You can do

[lua] R = math.random(0,255)
G = math.random(0,255)
b = math.random(0,255)[/lua]

on top and then do.

[lua]SetTextColor(Color(R,G,B))[/lua]

Better go with a square wave.

https://d16l38yicn0lym.cloudfront.net/fk7ld8XlXTh.png

Ok Im confused I just want flashy chat tags

This is my current code


if ( SERVER ) then
	
	-- Before someone complains: Garry changed it so that if it's called without an arg it adds the current file
	AddCSLuaFile( )
	
	return
end

 SetTextColor(Color(R,G,B))
 R = math.random(0,255)
 G = math.random(0,255)
 b = math.random(0,255)
 

-- For evolve change all GetUserGroup to EV_GetRank
-- Adding more Tags is as simple as TagColor["example"] = Color( 0, 0, 0 )
-- The  numbers mean r g b, red green blue.
-- All TagColor's have to be under the local TagColor = {}

local TagColor = {}

TagColor["Superadmin"] = Color( 255, 0, 0)
TagColor["Admin"] = Color( 0, 255, 255 )
TagColor["Owner"] = Color( 255, 132, 0 )
TagColor["T-VIP"] = Color( 161, 0, 255 )
TagColor["M-VIP"] = Color( 153, 153 ,153 )
TagColor["VIP"] = Color( 255, 255, 0 )
TagColor["Mod"] = Color( 0, 255, 0 )

local function OnPlayerChat( ply, strText, bTeamOnly, bPlayerIsDead )

	local tab = {}

	if ( bPlayerIsDead ) then
		table.insert( tab, Color( 255, 30, 40 ) )
		table.insert( tab, "|DEAD| " )
	end

	if ( bTeamOnly ) then
		table.insert( tab, Color( 30, 160, 40 ) )
		table.insert( tab, "|TEAM|" )
	end
	
	if ( IsValid( ply ) ) then

		if ( ply.GetUserGroup ) then
			if ( ply:GetUserGroup() != "user" ) then
				table.insert( tab, TagColor[ ply:GetUserGroup() ] or Color(255, 255, 255 ) )
				table.insert( tab, "[" .. ply:GetUserGroup() .. "]" )
			end
		end

		table.insert( tab, ply:GetName() )
	else
		table.insert( tab, "Console" )
	end
 
	table.insert( tab, Color( 255, 255, 255 ) )
	table.insert( tab, ": "..strText )
 
	chat.AddText( unpack(tab) )
 
	return true

end

hook.Add("OnPlayerChat", "Tags.OnPlayerChat", OnPlayerChat)


But I dont know how to make it flash? :frowning:

You need a custom chatbox, first of all. I don’t think it’s possible with the default one.

Then it flashes between two colors and not a range of them.

PS. If I wanted to use alternating between two values based on time I would just use modulo.

Color(r, g, b, (RealTime() % 1 < 0.5) and 255 or 0)

Okay find it kind of weird some random person just decided to copy and paste a code on here. This is for a score board. Haven’t dealt with this stuff before.

[lua]local glow = math.abs(math.sin(CurTime() * 2) * 255);
local flashingRed = Color(glow, 0, 0, 255); – This flashes red.
local flashingGreen = Color(0, glow, 0); – This flashes green.
local flashingBlue = Color(0, 0, glow); – This flashes blue. [/lua]

then would put the glow on the text that I wanted to flash but that didn’t work out so well.
hmm thanks for your guys help tho just having a problem with this one.

figured it out thanks everyone.