How to make a chat command do something.

Hi guys, I was wondering how can I make a chat command do something, lets say I type !sam kill Wilki
It will run kill on the name. That is all I need to know, once I know that I can work it out for myself.

[lua]function ChatCommands(pl,text,toall)
local args = string.Explode(" ",text)
– DO stuff with args, like you would a concommand

So would I use
[lua]function ChatCommands(pl,text,toall)
local args = string.Explode(" ",kill)

How can I stop it from showing the command in chat?

Return an empty string between lines 28 and 29 (In Conna’s code).


[lua]hook.Add(“PlayerSay”, “MyCommandsThing”, function(plyObject, saidText, isPublic)
local arguments = string.Explode(" ", saidText); – Seperate the text we typed by spaces.

-- Did we type '!kill' and did we type anything after that?
if (arguments[1] == "!kill" and arguments[2] and arguments[2] != "") then
	-- Excellent, now let's find a player to kill!
	local findName = string.lower( arguments[2] ); -- Put the string we're searching for in lower-case.
	local killedPlayers = {}; -- A table to store who we've killed.
	-- Loop through every player, we're gonna try and match names with what we typed.
	for k, v in ipairs( player.GetAll() ) do
		-- Does this player's lower-case name contain what we're looking for?
		if ( string.find(string.lower( v:Name() ), findName) ) then
			-- Great! We've got our player, let's kill 'em!
			-- Now let's put them into our killed players table.
			killedPlayers[#killedPlayers + 1] = v:Name();
	-- Did we kill any players?
	if (#killedPlayers > 0) then
		-- Send a message to everyone!
		for k, v in ipairs( player.GetAll() ) do
			v:PrintMessage(3, "[MyCommandsThing] "..plyObject:Name().." has killed "..table.concat(killedPlayers, ", and ")..".");
	return "";


Whoops, forgot that. Cheers.

EDIT: I’m stupid