Disable chat command echo

Hello, I wanted to know how to “fix” that: we use the manage_chat_tags addon for TTT, and I tried using the garrysmod wiki tutorial for PlayerSay to make chat commands, and in the example it also shows how to remove the command, but the command doesnt work at all ingame? singleplayer it works though…

I don’t understand what you’re asking.

[editline]17th February 2015[/editline]

Well, If you mean for example “!help”, and you want to make it do something without “!help” printing in the chat box in the PlayerSay hook, you would make it


return ""

[editline]17th February 2015[/editline]


hook.Add("PlayerSay", "chatCommands", function(ply, text, public) 
	
	if string.sub(string.lower(text), 1, 9) == "!kickbots" then
		if #player.GetBots() > 0 then
			for _, bot in pairs(player.GetBots()) do
					bot:Kick("Bot Kicked")
			end
			NotifyMsg({Color(50,150,255), ply:Nick(), color_white, " kicked all bots"}, "notification")
		else
			NotifyMsg({color_white, "There are no bots currently online."}, "notification", ply)
		end
	return ""
	end
end)

But what if they write stuff like “!kickbot blah blah” and I want to return the text minus the command(what I did like in the wiki), but the commands just wont display right, like it still shows the whole command, but it wont output a error.

Sorry, I’m having trouble understanding your issue, I would love to help you.

well, lets say, we use the manage_chat_tags addon, and when I try to code something like a custom !me addon which should show stuff like

Name: ** blah blah

and the command would be ‘!me blah blah’
and I’d use the string.sub return example from the gmod wiki, it still shows
‘!me blah blah’ and the chat is normal.

I’m not entirely sure what the chat tag addon is but I can guess it’s ULX.

If you want a command like “!msg Hello World” to print to console like “Name: Hello World” you could use the string.Explode function which an appropriate split, this will separate the string into a table where you can select positions in the table.

I’ll post the chat tag addon here:



// Client Side
// Originally Made By: TyGuy
// Edited By: Mr. Apple

local Tags = 
{
--Group    --Tag     --Color
{"tmoderator", "[TRIAL-MOD]", Color(243, 156, 18, 255) },
{"moderator", "[MOD]", Color(241, 196, 15, 255) },
{"admin", "[ADMIN]", Color(211, 84, 0, 255) },
{"superadmin", "[SUPERADMIN]", Color(230, 126, 34, 255) },
{"coowner", "[CO-OWNER]", Color(192, 57, 43, 255) },
{"owner", "[OWNER]", Color(231, 76, 60, 255) },
}

hook.Add("OnPlayerChat", "Tags", function(ply, Text, Team, PlayerIsDead)
	if ply:IsValid() then
		for k,v in pairs(Tags) do
			if ply:IsUserGroup(v[1]) then
				if Team then
						if ply:Alive() then
							chat.AddText(Color(0, 204, 0, 255), "{TEAM} ", v[3], v[2], Color(50, 50, 50, 255), " ", v[3], ply:Nick(), color_white, ": ", Color(255, 255, 255, 255), Text)
						else
							chat.AddText(Color(255, 0, 0, 255), "*DEAD*", Color(0, 204, 0, 255), "{TEAM} ", v[3], v[2], Color(50, 50, 50, 255), " ", v[3], ply:Nick(), color_white, ": ", Color(255, 255, 255, 255), Text)
						end
						return true
				end
				if ply:IsPlayer() then
					if ply:Alive() then
						chat.AddText(Color(255, 0, 0, 255), "", v[3], v[2], Color(50, 50, 50, 255), " ", v[3], ply:Nick(), color_white, ": ", Color(255, 255, 255, 255), Text)
						return true
					elseif !ply:Alive() then
						chat.AddText(Color(255, 0, 0, 255), "*DEAD* ", v[3], v[2], Color(50, 50, 50, 255), " ", v[3], ply:Nick(), color_white, ": ", Color(255, 255, 255, 255), Text)
						return true
					end
				end
			end
		end
	end
end)