Chatbox w/ Admin Tags

Hello,
I been attempting to create a custom chatbox and put admin tags by people’s names.
I have a sandbox server using the ASS Mod (Latest).
Me and my friend Tobba have been sitting on the wiki for about 6 hours now, and we still fail.
If anyone could comply a script, please do.
I am considering to switch to the Uber admin system, or to the GManage.
If there is a way to just input a steam ID into a text file and have the tag come up by their name, that would be great.

Thanks in advance,
Odahilys.

[lua]
function AdminTags( ply,txt )
if ( ply:IsAdmin() ) then
return “(” … ply:Team():GetName() … ") " … txt
else
return txt
end
end
hook.Add( “PlayerSay”,“AdminTags”,AdminTags )
[/lua]

Havnt tested it but it should add the players rank if they are an admin.

edit: oops, forgot that this will just add their rank into their message and not infront of their name :S

Here’s a scrip the server DarkLand Roleplay uses.
[LUA]surface.CreateFont( “Tahoma”, 16, 1000, true, false, “DarklandChatBox” )
function FluctuateColor(a)
a = a or 1
return math.abs(math.sin(CurTime()*a))
end
teamchat = false
chaton = false

local realtext = “”
local chattext = “”
local maxlines = 10
local history = {}
local cursorpos = 0

local COLOR_CHAT = Color( 255, 255, 255, 255 )
local COLOR_CONSOLE = Color( 217, 0, 25, 255 )
local COLOR_WHISPER = Color( 101, 202, 36, 255 )
local COLOR_NOTIFY = Color( 101, 202, 36, 255 )
local COLOR_HINT = Color( 77, 131, 240, 255 )

function AddHistory( pl, msg, type )

type = tonumber(type) or 0

local col = COLOR_CONSOLE
if type == 1 then
	col = COLOR_CHAT
elseif type == 2 then
	col = COLOR_WHISPER
elseif type == 3 then
	col = COLOR_NOTIFY
elseif type == 4 then
	col = COLOR_HINT
end
	if pl == 0 then pl = nil end
	if tonumber(pl) == pl  then
		for k, v in pairs( player.GetAll() ) do
			if v:UserID() == pl then
				pl = v
				break
			end
		end
	end
if pl and pl:IsPlayer() and pl.UserID then
		local r,g,b,a = pl:GetColor()
		local color = Color( r, g, b, 255 )
		if (	r == 255	and
			g == 255	and
			b == 255	and
			a == 255	) then
			color = team.GetColor( pl:Team() )
		end
		local chatInfo = {
			pl = pl,
			admin = pl:IsAdmin(),
			name = pl:GetName(),
			color = color,
			textcolor = col,
			msg = msg,
			type = type or 1,
			time = RealTime()+10
		};
	if type == 5 then
		print("PM from " .. pl:GetName().." - "..msg)		
	elseif type == 6 then
		chatInfo = {
			pl = pl,
			admin = false,
			name = "(Advert)",
			color = Color(46,116,24,255),
			textcolor = Color(255,255,255,255),
			msg = msg,
			type = type or 1,
			time = RealTime()+10
		};
	elseif type == 7 then
		chatInfo = {
			pl = pl,
			admin = false,
			name = "(Request)",
			color = Color(66,218,241,255),
			textcolor = Color(255,255,255,255),
			msg = msg,
			type = type or 1,
			time = RealTime()+10
		};
	elseif type == 8 then
		chatInfo = {
			pl = pl,
			admin = false,
			name = "(Radio)",
			color = Color(43,117,208,255),
			textcolor = Color(255,255,255,255),
			msg = msg,
			type = type or 1,
			time = RealTime()+10
		};
	elseif type == 9 then
		chatInfo = {
			pl = pl,
			admin = false,
			name = "(Broadcast)",
			color = Color(225,96,51,255),
			textcolor = Color(255,255,255,255),
			msg = msg,
			type = type or 1,
			time = RealTime()+10
		};
	elseif type == 10 then
		chatInfo = {
			admin = false,
			color = Color(225,128,0,255),
			textcolor = Color(255,128,0,255),
			msg = pl:GetName().." "..msg,
			type = type or 1,
			time = RealTime()+10
		};
		print(pl:GetName().." "..msg)
	elseif type == 11 then
		chatInfo = {
			pl = pl,
			admin = false,
			name = "(Gang)",
			color = Color(80,80,80,255),
			textcolor = Color(255,255,255,255),
			msg = msg,
			type = type or 1,
			time = RealTime()+10
		};
	elseif type == 12 then
		chatInfo = {
			pl = pl,
			admin = true,
			name = pl:Name(),
			color = Color(43,117,208,255),
			textcolor = Color(120,120,255,255),
			msg = msg,
			type = type or 1,
			time = RealTime()+10
		};
	end
	table.insert(history,1,chatInfo)
else
		local chatInfo = {
		textcolor = col,
		msg = msg,
		type = type or 1,
		time = RealTime()+10
	};
	table.insert(history,1,chatInfo)
end
history[maxlines+1] = nil

end

usermessage.Hook("__chatprint",function(um) local msg = um:ReadString() AddHistory(NULL,msg,0) print(msg) end)
function OnPlayerChat( player, msg )
if !IsValid(player) then
AddHistory( nil, msg, 0 )
print(msg)
else
local name = player:Name()
AddHistory( player, msg, 1 )
MsgN(name…": "…msg)
end
return true
end
hook.Add(“OnPlayerChat”,“SeriousChat”,OnPlayerChat)
function TW(s,f)
local w = surface.GetTextSize(s,f)
return w
end
function ChatPaint()

local x, y = 80, ScrH()-140
if ChatOffset then 
	x = ChatOffset.x or x 
	y = ChatOffset.y or y 
end
local num = 0
local total = 0
for i,v in pairs(history) do
	if v.time > RealTime() or chaton then
		if v.pl then
			local x2 = x
			if v.admin and v.pl:GetNWBool("disguised") == false then
				draw.SimpleText("(Admin)","DarklandChatBox",x-4,(y-i*15)+1,Color(0,0,0,255),2)
				draw.SimpleText("(Admin)","DarklandChatBox",x-5,(y-i*15),Color(FluctuateColor(2)*255,0,0,255),2)
			end
			draw.SimpleText(v.name,"DarklandChatBox",x+1,(y-i*15)+1,Color(0,0,0,255))
			draw.SimpleText(v.name,"DarklandChatBox",x,y-i*15,v.color)
			
			x2 = x2+TW(v.name,"DarklandChatBox")+1
			draw.SimpleText(": "..v.msg,"DarklandChatBox",x2+1,(y-i*15)+1,Color(0,0,0,255))
			draw.SimpleText(": "..v.msg,"DarklandChatBox",x2,y-i*15,v.textcolor)
		else
			draw.SimpleText(v.msg,"DarklandChatBox",x+1,(y-i*15)+1,Color(0,0,0,255))
			draw.SimpleText(v.msg,"DarklandChatBox",x,y-i*15,v.textcolor)
		end
	end
end

-- Draw text input
if chaton then

	local prefix = "Say"
	if string.find(GAMEMODE.Name,"RP") then
		if string.find( realtext, "//" ) == 1 then
			prefix = "OOC"
		elseif string.find( realtext, "/y" ) == 1 then
			prefix = "Yell"
		elseif string.find( realtext, "/w" ) == 1 then
			prefix = "Whisper"
		elseif teamchat then
			prefix = "Team"
		elseif string.find( realtext, "/" ) == 1 then
			prefix = "Cmd"
		end
	end
	local endstring = prefix..": "..chattext

	local w, h = surface.GetTextSize( endstring )

	if prefix ~= "Cmd" then
		cursorpos = w
	end

	draw.RoundedBox( 4, x-5, y+5, w+14, h+1, Color( 0, 0, 0, 200 ) )

	surface.SetTextColor( 255, 255, 255, 255 )

	surface.SetTextPos( x+2, y+5 )
	surface.DrawText( endstring )

	if ((math.sin(CurTime() * 5) * 10) > 0) then
		surface.SetTextPos( x+cursorpos+1, y+5 )
		surface.DrawText( "|" )
	end

end

end
hook.Add(“HUDPaint”,“DrawChat”,ChatPaint)
function StartChat()
chaton = true
return true
end
hook.Add(“StartChat”,“SeriousStartChat”,StartChat)
function FinishChat()
chaton = false
teamchat = false
chattext = “”
realtext = “”
end
hook.Add(“FinishChat”,“SeriousFinishChat”,FinishChat)
function ChatTextChanged( text )
realtext = text
if string.find( text, “/” ) ~= 1 then
chattext = text
else
if string.len(text) > 1 then
chattext = string.Right( text, string.len(text)-1 )
chattext = CommandHelp( chattext )
else
chattext = “”
chattext = CommandHelp( chattext )
end
end
end
hook.Add(“ChatTextChanged”,“ChatMoved”,ChatTextChanged)
function CommandHelp( command )
surface.SetFont( “ScoreboardText” )
local prefix = “Cmd: "
local text = command
local sep = string.Explode(” “, text)
local w, h = surface.GetTextSize( prefix…text )
cursorpos = w
if sep[1] == “givemoney” then
if !sep[2] then
sep[2] = “{Amount}”
else
sep[2] = “{”…sep[2]…” }"
w, h = surface.GetTextSize( prefix…text…"{" )
cursorpos = w
end
elseif string.find(sep[1],"/") == 1 then
sep[1] = string.sub(sep[1],2)
elseif sep[1] == “w” then
sep[1] = “”
elseif sep[1] == “y” then
sep[1] = “”
end

return string.Implode( " ", sep )

end

function StartTeamChat(ply, bind)
if string.find( bind, “messagemode2” ) then
teamchat = true
end
end
hook.Add(“PlayerBindPress”, “TeamChat”, StartTeamChat )[/LUA]
The OOC and stuff is in RP only, so don’t worry. If you are RP, i think you should just remove.
This does NOT support assmod, or any of the ULX like scripts. Console will still have the messages ( at least for assmod)

Where would this go? and would it work with gmodrp?

Use your brain for once. And, why are you a server owner if you dont even know the basics of lua? And next time, please dont quote huge posts. Sorry if im being horrible, but damn. You have been giving me a headache lately.

It goes in cl_init.

How do you disguise yourself from the admin flashing thing ingame?

Dont use that. Code your own.