Chat Prefixs (Titles) for TTT

So I have this script for Chat Titles in TTT but as you can see in the script, it displays your {TEAM}.


function ChatTags(ply, Text, Team, PlayerIsDead)
if Team then
			local nickteamcolor = team.GetColor(ply:Team())
			local nickteam = team.GetName(ply:Team())
			if ply:Alive() then
			chat.AddText(Color(255, 0, 0, 255), "{TEAM} ", nickteamcolor, nickteam, Color(50, 50, 50, 255), "| ", nickteamcolor, ply:Nick(), color_white, ": ", Color(255, 255, 255, 255), Text)
			else
			chat.AddText(Color(255, 0, 0, 255), "*DEAD* {TEAM} ", nickteamcolor, nickteam, Color(50, 50, 50, 255), "| ", nickteamcolor, ply:Nick(), color_white, ": ", Color(255, 255, 255, 255), Text)
			end
			return true
end
if ply:IsPlayer() then
if ply:Alive() then
			local nickteamcolor = team.GetColor(ply:Team())
			local nickteam = team.GetName(ply:Team())
			chat.AddText(Color(255, 0, 0, 255), "", nickteamcolor, nickteam, Color(50, 50, 50, 255), "| ", nickteamcolor, ply:Nick(), color_white, ": ", Color(255, 255, 255, 255), Text)
			return true
elseif !ply:Alive() then
			local nickteamcolor = team.GetColor(ply:Team())
			local nickteam = team.GetName(ply:Team())
			chat.AddText(Color(255, 0, 0, 255), "*DEAD* ", nickteamcolor, nickteam, Color(50, 50, 50, 255), "| ", nickteamcolor, ply:Nick(), color_white, ": ", Color(255, 255, 255, 255), Text)
			return true
end
end
end
hook.Add("OnPlayerChat", "Tags", ChatTags)

I want it to display multiple UserGroups from ULX.

Change all instances of team.GetName(ply:Team()) to ply:GetNWString(“usergroup”). You might also want to change the string configuration.

How would one do that I’m really amatuer at lua

Then edit the group (where it says (“usergroup”)) to whatever you want it to be. Then edit the color you want the text to be.

Uh, no. You are getting the usergroup network string; he shouldn’t change “usergroup.”

Where should I put the usergroup. This is what I have so far.




function ChatTags(ply, Text, Team, PlayerIsDead)
if Team then
			local nickteamcolor = team.GetColor(ply:Team())
			local nickteam = ply:GetNWString("usergroup")
			if ply:Alive() then
			chat.AddText(Color(255, 255, 0, 255), "usergroup ", nickteamcolor, nickteam, Color(50, 50, 50, 255), "| ", nickteamcolor, ply:Nick(), color_white, ": ", Color(255, 255, 255, 255), Text)
			else
			chat.AddText(Color(255, 255, 0, 255), "*DEAD* {TEAM} ", nickteamcolor, nickteam, Color(50, 50, 50, 255), "| ", nickteamcolor, ply:Nick(), color_white, ": ", Color(255, 255, 255, 255), Text)
			end
			return true
end
if ply:IsPlayer() then
if ply:Alive() then
			local nickteamcolor = team.GetColor(ply:Team())
			local nickteam = ply:GetNWString("usergroup")
			chat.AddText(Color(255, 255, 0, 255), "", nickteamcolor, nickteam, Color(50, 50, 50, 255), "| ", nickteamcolor, ply:Nick(), color_white, ": ", Color(255, 255, 255, 255), Text)
			return true
elseif !ply:Alive() then
			local nickteamcolor = team.GetColor(ply:Team())
			local nickteam = ply:GetNWString("usergroup")
			chat.AddText(Color(255, 255, 0, 255), "*DEAD* ", nickteamcolor, nickteam, Color(50, 50, 50, 255), "| ", nickteamcolor, ply:Nick(), color_white, ": ", Color(255, 255, 255, 255), Text)
			return true
end
end
end
hook.Add("OnPlayerChat", "Tags", ChatTags)

That should work.

Right I should actually read the code before answering.

Yes but I want to add titles for it.
Ex: Owner | Zoombiee: Hi

[editline]5th June 2014[/editline]

Instead of saying Spectator/Terrorist ({TEAM})

This might help

So where do I insert the


local Tags = 
{
--Group    --Tag     --Color
{"admin", "ADMIN", Color(0, 0, 255, 255) },
{"superadmin", "SUPERADMIN", Color(255, 0, 0, 255) },
{"owner", "OWNER", Color(0, 255, 0, 255) }
}

It’s a different addon.

So instead of my script I just put that file in the lua/autorun

lua/autorun/client

The script works, but all the chat text comes up in red. Any way to change this?


CreateClientConVar("chat_tags_color_r", 255, true, false)
CreateClientConVar("chat_tags_color_g", 0, true, false)
CreateClientConVar("chat_tags_color_b", 0, true, false)
CreateClientConVar("chat_tags_color_a", 255, true, false)

local Tags = 
{
--Group    --Tag     --Color
{"admin", "[Administrator] ", Color(0, 0, 255, 255) },
{"superadmin", "[S. Administrator] ", Color(128, 0, 128, 255) },
{"Developer", "[Developer] ", Color(255, 255, 0, 255) },
{"Owner", "[Owner] ", Color(139, 0, 0, 255) }
}

hook.Add("OnPlayerChat", "Tags", function(ply, strText, bTeamOnly)
	for k,v in pairs(Tags) do
		if ply:IsUserGroup(v[1]) then
			local R = GetConVarNumber("chat_tags_color_r")
			local G = GetConVarNumber("chat_tags_color_g")
			local B = GetConVarNumber("chat_tags_color_b")
			local A = GetConVarNumber("chat_tags_color_a")
			local nickteam = team.GetColor(ply:Team())
				if !bTeamOnly then
			chat.AddText(v[3], v[2], nickteam, ply:Nick(), color_white, ": ", Color(R, G, B, A), strText)
			return true
				else
			chat.AddText(v[3], v[2], nickteam, "(TEAM) ", ply:Nick(), color_white, ": ", Color(R, G, B, A), strText)
			return true
			end
		end
	end
end )

Edit these lines using a RGB chart.
(The 4th segment is the transparency of it so it’s RGBA)


local Tags = 
{
--Group    --Tag     --Color
{"admin", "[Administrator] ", Color(0, 0, 255, 255) },
{"superadmin", "[S. Administrator] ", Color(128, 0, 128, 255) },
{"Developer", "[Developer] ", Color(255, 255, 0, 255) },
{"Owner", "[Owner] ", Color(139, 0, 0, 255) }
}

Yes, but the chat still appears red.
Ex: [Developer] Zoombie: hi(red)

[editline]5th June 2014[/editline]

http://puu.sh/9gtDI/3611c8918d.jpg

My mistake. Edit the RGBA here (change all to 255)


CreateClientConVar("chat_tags_color_r", 255, true, false)
CreateClientConVar("chat_tags_color_g", 0, true, false)
CreateClientConVar("chat_tags_color_b", 0, true, false)
CreateClientConVar("chat_tags_color_a", 255, true, false)

I tried that last time because it seemed pretty evident, but I changed them to 0 instead of 255, maybe it will work if I change them to 255 instead of 0.

Changing them all to 255 will make them white. It seems you only left R at 255 and A at 255 so it’d only be red than white.