Ulysses Stuff > Releases

Custom Chat Colors

<< < (5/6) > >>

Valgoid:

--- Quote from: Cobalt on June 07, 2014, 09:52:24 PM ---No a thing where you can set the color of your text by doing `color` text, the chat tags part wasn't relevent

--- End quote ---

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.

Cobalt:

--- Code: ---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

--- End code ---

Valgoid:
So basically the player types for example "color red" and it changes their chat color to red?

Cobalt:

--- Quote from: Valgoid 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?

--- End quote ---
`red` text -> text
`255 0 0` text -> text

Valgoid:
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?

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version