Dead players in global chat (chat tags)

I started this thread: http://forum.facepunch.com/showthread.php?t=1385530&p=44561032#post44561032

and was told the reason dead players were showing up on global chat when killed by the world on my TTT server was because there was an error with the code for my chat tags. I was wondering if you could find the problem and help my fix this.

This is the cc_chattags.lua file:


if ( SERVER ) then

	AddCSLuaFile( )
	
	return
	
end

if ( CLIENT ) then

local string = string

local str = string

local str2

local TagColor = {}

--TagColor["Owner"] = Color( 0, 0, 255 )

TagColor["operator"] = Color( 0, 255, 0 )

TagColor["admin"] = Color( 220, 180, 0 )

TagColor["superadmin"] = Color( 255, 0, 0 )

local function OnPlayerChat( ply, strText, bTeamOnly, bPlayerIsDead )

	local tab = {}
	
	local defcol = Color( 0, 201, 0 )

	if ( bPlayerIsDead ) then
	
		table.insert( tab, Color( 255, 30, 40 ) )
		
		table.insert( tab, "*DEAD* " )
		
	end
	
	if ( bTeamOnly ) then
	
		table.insert( tab, Color( 30, 160, 40 ) )
		
		table.insert( tab, "(TEAM) " )
		
	end
	
	if ( IsValid( ply ) ) then
	
		if ( ply.GetUserGroup ) then
		
			if ( ply:GetUserGroup() ~= "user" ) then
			
				table.insert( tab, TagColor[ ply:GetUserGroup() ] or Color( 255, 255, 255 ) )
				
				str = ply:GetUserGroup()
				
				str2 = str
				
				if string.find( str2, "%s" ) then
				
					string.sub( str2, string.find( str2, "%s" ), string.len( str2 ) )
					
					str2 = str2:gsub( "^%l", string.upper )
					
				end
				
				str = str:gsub( "^%l", string.upper )
				
				table.insert( tab, "[" .. str .. "] " )
				
			end
			
		end

		table.insert( tab, defcol )
		
		table.insert( tab, ply:GetName() )
		
	else
	
		table.insert( tab, "Console" )
		
	end

	table.insert( tab, Color( 255, 255, 255 ) )
	
	table.insert( tab, ": "..strText )
 
	chat.AddText( unpack( tab ) )
 
	return true
	
end
hook.Add( "OnPlayerChat", "Tags.OnPlayerChat", OnPlayerChat )

end --End clientside 


Technically TTT players aren’t “dead”, so do a check with

[lua]ply:IsTerror() – to see if they’re “Alive” or !ply:IsTerror() if they’re “Dead (aka Unidentified/Confirmed/Spectator)”[/lua]

[lua]function PlayerCheck( ply )

for k,v in pairs( player.GetAll() ) do
	if ( v:IsTerror() ) then
 --Code here

end [/lua]

[editline]16th April 2014[/editline]

[lua]function PlayerCheck( ply )

for k,v in pairs( player.GetAll() ) do
	
	if ( v:IsTerror() ) then

if ( SERVER ) then

AddCSLuaFile( )

return

end

if ( CLIENT ) then

local string = string

local str = string

local str2

local TagColor = {}

–TagColor[“Owner”] = Color( 0, 0, 255 )

TagColor[“operator”] = Color( 0, 255, 0 )

TagColor[“admin”] = Color( 220, 180, 0 )

TagColor[“superadmin”] = Color( 255, 0, 0 )

local function OnPlayerChat( ply, strText, bTeamOnly, bPlayerIsDead )

local tab = {}

local defcol = Color( 0, 201, 0 )

if ( bPlayerIsDead ) then

	table.insert( tab, Color( 255, 30, 40 ) )
	
	table.insert( tab, "*DEAD* " )
	
end

if ( bTeamOnly ) then

	table.insert( tab, Color( 30, 160, 40 ) )
	
	table.insert( tab, "(TEAM) " )
	
end

if ( IsValid( ply ) ) then

	if ( ply.GetUserGroup ) then
	
		if ( ply:GetUserGroup() ~= "user" ) then
		
			table.insert( tab, TagColor[ ply:GetUserGroup() ] or Color( 255, 255, 255 ) )
			
			str = ply:GetUserGroup()
			
			str2 = str
			
			if string.find( str2, "%s" ) then
			
				string.sub( str2, string.find( str2, "%s" ), string.len( str2 ) )
				
				str2 = str2:gsub( "^%l", string.upper )
				
			end
			
			str = str:gsub( "^%l", string.upper )
			
			table.insert( tab, "[" .. str .. "] " )
			
		end
		
	end

	table.insert( tab, defcol )
	
	table.insert( tab, ply:GetName() )
	
else

	table.insert( tab, "Console" )
	
end

table.insert( tab, Color( 255, 255, 255 ) )

table.insert( tab, ": "..strText )

chat.AddText( unpack( tab ) )

return true

end
hook.Add( “OnPlayerChat”, “Tags.OnPlayerChat”, OnPlayerChat )

end --End clientside
end[/lua]

so what do I do with this?

[editline]16th April 2014[/editline]

Sorry, obviously replace the code with this, seeing if it works now.

[editline]16th April 2014[/editline]

getting this error:


[ERROR] addons/customcommands_onecategory/lua/ulx/modules/sh/cc_chattags.lua:110: 'end' expected (to close 'for' at line 7) near '<eof>'
  1. unknown - addons/customcommands_onecategory/lua/ulx/m

You’re missing an end.

I got that part, but i don’t know where to put it.



function PlayerCheck( ply )
	for k,v in pairs( player.GetAll() ) do
		if ( v:IsTerror() ) then


You’ve done something here. I just cant – what exactly are you going for?
Also like nooky said you need to check for !ply:IsTerror()

That’s just what Mr Plonker said to do, and how do I check for !ply:IsTerror()

[lua]function PlayerCheck( ply )

for k,v in pairs( player.GetAll() ) do
	
	if ( v:IsTerror() ) then

if ( SERVER ) then

AddCSLuaFile( )

return 

end
end

if ( CLIENT ) then

local string = string

local str = string

local str2

local TagColor = {}

–TagColor[“Owner”] = Color( 0, 0, 255 )

TagColor[“operator”] = Color( 0, 255, 0 )

TagColor[“admin”] = Color( 220, 180, 0 )

TagColor[“superadmin”] = Color( 255, 0, 0 )

local function OnPlayerChat( ply, strText, bTeamOnly, bPlayerIsDead )

local tab = {}

local defcol = Color( 0, 201, 0 )

if ( bPlayerIsDead ) then

	table.insert( tab, Color( 255, 30, 40 ) )
	
	table.insert( tab, "*DEAD* " )
	
end

if ( bTeamOnly ) then

	table.insert( tab, Color( 30, 160, 40 ) )
	
	table.insert( tab, "(TEAM) " )
	
end

if ( IsValid( ply ) ) then

	if ( ply.GetUserGroup ) then
	
		if ( ply:GetUserGroup() ~= "user" ) then
		
			table.insert( tab, TagColor[ ply:GetUserGroup() ] or Color( 255, 255, 255 ) )
			
			str = ply:GetUserGroup()
			
			str2 = str
			
			if string.find( str2, "%s" ) then
			
				string.sub( str2, string.find( str2, "%s" ), string.len( str2 ) )
				
				str2 = str2:gsub( "^%l", string.upper )
				
			end
			
			str = str:gsub( "^%l", string.upper )
			
			table.insert( tab, "[" .. str .. "] " )
			
		end
		
	end

	table.insert( tab, defcol )
	
	table.insert( tab, ply:GetName() )
	
else

	table.insert( tab, "Console" )
	
end

table.insert( tab, Color( 255, 255, 255 ) )

table.insert( tab, ": "..strText )

chat.AddText( unpack( tab ) )

return true

end
hook.Add( “OnPlayerChat”, “Tags.OnPlayerChat”, OnPlayerChat )

end --End clientside
end[/lua]
Try that.