Author Topic: Custom Chat Colors  (Read 23180 times)

0 Members and 1 Guest are viewing this topic.

Offline Exile

  • Newbie
  • *
  • Posts: 5
  • Karma: -1
Re: Custom Chat Colors
« Reply #15 on: June 05, 2014, 07:47:24 PM »
Does this work or?

Offline Valgoid

  • Full Member
  • ***
  • Posts: 103
  • Karma: -15
  • Wanna Be Lua King
Re: Custom Chat Colors
« Reply #16 on: June 07, 2014, 09:25:32 PM »
Someone should really remake this so it works!

Offline Cobalt

  • Full Member
  • ***
  • Posts: 216
  • Karma: 44
  • http://steamcommunity.com/id/__yvl/
Re: Custom Chat Colors
« Reply #17 on: June 07, 2014, 09:43:42 PM »
I have something similar in some chat tags I made for my gamemode, if anyone wants it I will post the code here.

Offline Valgoid

  • Full Member
  • ***
  • Posts: 103
  • Karma: -15
  • Wanna Be Lua King
Re: Custom Chat Colors
« Reply #18 on: June 07, 2014, 09:50:15 PM »
I have something similar in some chat tags I made for my gamemode, if anyone wants it I will post the code here.

You mean chat tags, that you can color?

Offline Cobalt

  • Full Member
  • ***
  • Posts: 216
  • Karma: 44
  • http://steamcommunity.com/id/__yvl/
Re: Custom Chat Colors
« Reply #19 on: June 07, 2014, 09:52:24 PM »
You mean chat tags, that you can color?
No a thing where you can set the color of your text by doing `color` text, the chat tags part wasn't relevent

Offline Valgoid

  • Full Member
  • ***
  • Posts: 103
  • Karma: -15
  • Wanna Be Lua King
Re: Custom Chat Colors
« Reply #20 on: June 07, 2014, 10:13:12 PM »
No a thing where you can set the color of your text by doing `color` text, the chat tags part wasn't relevent

Oh, so if I wanted to change me color to yellow, i would just type color, something like that? If it is like that, It would be great if you would share it with us.

Offline Cobalt

  • Full Member
  • ***
  • Posts: 216
  • Karma: 44
  • http://steamcommunity.com/id/__yvl/
Re: Custom Chat Colors
« Reply #21 on: June 07, 2014, 10:15:13 PM »
Code: [Select]
local groups = {
{ "vip", Color( 0, 200, 0 ), "VIP" },
{ "betatester", Color( 180, 180, 180 ), "Beta Tester" },
{ "vip+", Color( 0, 255, 0 ), "VIP+" },
{ "owner", Color( 255, 0, 0 ), "Owner" },
{ "creator", Color( 200, 0, 0 ), "Creator" },
{ "coowner", Color( 255, 0, 0 ), "Co-Owner" },
{ "superadmin", Color( 255, 0, 0 ), "Superadmin" },
{ "admin", Color( 220, 180, 0 ), "Admin" }
}

local ccolors = {
{ "red", Color( 255, 0, 0 ) },
{ "blue", Color( 0, 0, 255 ) },
{ "yellow", Color( 255, 255, 0 ) },
{ "black", Color( 0, 0, 0 ) },
{ "white", Color( 255, 255, 255 ) },
{ "green", Color( 0, 255, 0 ) },
{ "orange", Color( 255, 120, 0 ) },
{ "pink", Color( 255, 0, 255 ) },
{ "purple", Color( 270, 0, 255 ) }
}

local ti = table.insert
local IsValid = IsValid
local Color = Color
local unpack = unpack
local white = color_white

function GM:OnPlayerChat( ply, text, teamonly, dead )
local tab = {}
if IsValid( ply ) then
if dead then
ti( tab, Color( 255, 30, 40 ) )
ti( tab, "*DEAD* " )
end
if teamonly then
ti( tab, Color( 30, 160, 40 ) )
ti( tab, "(TEAM) " )
end

local strcol = white
local customfound = false
for k, v in next, ccolors do
if string.StartWith( text, "`" .. v[ 1 ] .. "`" ) then
local pos = string.find( text, "`" .. v[ 1 ] .. "`" ) + v[ 1 ]:len()
text = string.sub( text, pos + 3 )
strcol = v[ 2 ]
customfound = true
end
end

if customfound == false and string.StartWith( text, "`" ) then
local exp = string.Explode( "`", text:sub( 2 ) )
local str = exp[ 1 ]
local str2 = string.Explode( " ", str )
if #str2 == 3 then
str2[ 4 ] = "255"
end
local col = string.ToColor( table.concat( str2, " " ) )
strcol = col or color_white
local pos = string.find( string.sub( text, 2 ), "`" )
text = string.sub( text, pos + 3 )
end

if ply:GetNWString( "usergroup" ) == "user" then
ti( tab, ply )
ti( tab, white )
ti( tab, ": " )
ti( tab, strcol )
ti( tab, text )
else
for k, v in next, groups do
if ply:GetNWString( "usergroup" ) == v[ 1 ] then
ti( tab, v[ 2 ] )
ti( tab, "[" .. v[ 3 ] .. "] " )
ti( tab, ply )
ti( tab, white )
ti( tab, ": " )
ti( tab, strcol )
ti( tab, text )
end
end
end
chat.AddText( unpack( tab ) )
return true
end
end

Offline Valgoid

  • Full Member
  • ***
  • Posts: 103
  • Karma: -15
  • Wanna Be Lua King
Re: Custom Chat Colors
« Reply #22 on: June 07, 2014, 10:21:01 PM »
So basically the player types for example "color red" and it changes their chat color to red?

Offline Cobalt

  • Full Member
  • ***
  • Posts: 216
  • Karma: 44
  • http://steamcommunity.com/id/__yvl/
Re: Custom Chat Colors
« Reply #23 on: June 07, 2014, 10:34:08 PM »
So basically the player types for example "color red" and it changes their chat color to red?
`red` text -> text
`255 0 0` text -> text

Offline Valgoid

  • Full Member
  • ***
  • Posts: 103
  • Karma: -15
  • Wanna Be Lua King
Re: Custom Chat Colors
« Reply #24 on: June 07, 2014, 11:03:45 PM »
For my server I use hat chat, and it has a built in tag system, do you think the script would work if I removed the local groups area in the script?

Offline Cobalt

  • Full Member
  • ***
  • Posts: 216
  • Karma: 44
  • http://steamcommunity.com/id/__yvl/
Re: Custom Chat Colors
« Reply #25 on: June 07, 2014, 11:18:23 PM »
For my server I use hat chat, and it has a built in tag system, do you think the script would work if I removed the local groups area in the script?
Probably not but you can try it.

Offline [U] Arcane Hero

  • Newbie
  • *
  • Posts: 7
  • Karma: 0
Re: Custom Chat Colors
« Reply #26 on: June 26, 2015, 05:07:15 PM »
Chat Color resets after a map change. Is there a way to make it a player's permanent color until they or someone else changes it?
« Last Edit: June 26, 2015, 05:30:38 PM by [U] Arcane Hero »