Chat tags not working properly

For some reason this only shows the Tag when someone talks and removes the player name altogether instead of adding it to the name… Example: [VIP] : hi

any ideas why?


-- free chat tags by rejax
-- dont need to edit core files you lazy bum 

local Tags = {}
Tags["superadmin"] = { Color( 255, 60, 50 ), "SuperAdmin", Color( 255, 60, 50 ) }
Tags["admin"] = { Color( 200, 90, 80 ), "Admin", Color( 200, 100, 100 ) }
Tags["vip"] = { Color( 50, 210, 50 ), "VIP", Color( 50, 255, 50 ) }

local function AddChatTags( ply, msg, team, dead, prefixText, col1, col2 )

if ply:Alive() then 
return false else
	
	if GAMEMODE.FolderName == "murder" then
		
		local text = {}
		local tag = Tags[ply:GetNWString("usergroup")]
		
		if tag then
			table.insert( text, tag[3] )
			table.insert( text, "[" )
			table.insert( text, tag[1] )
			table.insert( text, tag[2] )
			table.insert( text, tag[3] )
			table.insert( text, "] " )
		end
		
		table.insert( text, col1 )
		table.insert( text, prefixText )
		
		table.insert( text, col2 )
		table.insert( text, ": " .. msg )
		
		chat.AddText( unpack( text ) )
		
		return true
		end
	
	end

end
hook.Add( "OnPlayerChat", "ChatTags", AddChatTags )

You know, there no table.insert, wich add nick name. so add this like that:



-- free chat tags by rejax
-- dont need to edit core files you lazy bum 

local Tags = {}
Tags["superadmin"] = { Color( 255, 60, 50 ), "SuperAdmin", Color( 255, 60, 50 ) }
Tags["admin"] = { Color( 200, 90, 80 ), "Admin", Color( 200, 100, 100 ) }
Tags["vip"] = { Color( 50, 210, 50 ), "VIP", Color( 50, 255, 50 ) }

local function AddChatTags( ply, msg, team, dead, prefixText, col1, col2 )

if ply:Alive() then 
return false else
	
	if GAMEMODE.FolderName == "murder" then
		
		local text = {}
		local tag = Tags[ply:GetNWString("usergroup")]
		
		if tag then
			table.insert( text, tag[3] )
			table.insert( text, "[" )
			table.insert( text, tag[1] )
			table.insert( text, tag[2] )
			table.insert( text, tag[3] )
			table.insert( text, "] " )
		end
		
		table.insert( text, col1 )
		table.insert( text, prefixText )

		table.insert( text, col1 ) --Or other color wich you want
		table.incert( text, ply:GetName() )
		
		table.insert( text, col2 )
		table.insert( text, ": " .. msg )
		
		chat.AddText( unpack( text ) )
		
		return true
		end
	
	end

end
hook.Add( "OnPlayerChat", "ChatTags", AddChatTags )


Spelling error in Bold

I wrote these for darkrp, where the prefixText argument includes the name.

use these

[LUA]
– free chat tags by rejax
– dont need to edit core files you lazy bum

local Tags = {}
Tags[“superadmin”] = { Color( 255, 60, 50 ), “SuperAdmin”, Color( 255, 60, 50 ) }
Tags[“admin”] = { Color( 200, 90, 80 ), “Admin”, Color( 200, 100, 100 ) }
Tags[“vip”] = { Color( 50, 210, 50 ), “VIP”, Color( 50, 255, 50 ) }

local function AddChatTags( ply, msg, team, dead )

if ply:Alive() then
return false else

if GAMEMODE.FolderName == "murder" then
	
	local text = {}
	local tag = Tags[ply:GetNWString("usergroup")]
	
	if tag then
		table.insert( text, tag[3] )
		table.insert( text, "[" )
		table.insert( text, tag[1] )
		table.insert( text, tag[2] )
		table.insert( text, tag[3] )
		table.insert( text, "] " )
	end
	
	table.insert( text, ply:GetPlayerColor() ) -- i think this returns a vector so find a way to convert it to rgb
	table.insert( text, ply:Nick() )
	
	table.insert( text, color_white )
	table.insert( text, ": " .. msg )
	
	chat.AddText( unpack( text ) )
	
	return true
	end

end

end
hook.Add( “OnPlayerChat”, “ChatTags”, AddChatTags )
[/LUA]

i have writed by hand =\ sorry… Of cource it is “insert”

Thanks everyone who jumped on to help so quickly.

And thank you rejax for the awesome free code.

Works now.