Message2099

Author matthiaskrgr
Recipients
Date 2011-12-06.09:12:52
Content
That would be a great feature to have!

I did a very quick research and found this:

ChatCommands = {} -- Create the table to store the commands.

function AddChatCommand(cmd, callback)
	for k,v in pairs(ChatCommands) do 
		if cmd == v.cmd then return end	-- If it already exists then don't add another.
	end
	table.insert(ChatCommands, {cmd = cmd, callback = callback}) -- Add to the table.
end

function ChatCommandSay(ply, text)
	-- Loop through the table of chat commands.
	for k, v in pairs(ChatCommands) do
		if string.lower(v.cmd) == string.Explode(" ", string.lower(text))[1] then
			return v.callback(ply, "" .. string.sub(text, string.len(v.cmd) + 2,
string.len(text)))
		end
	end
end
hook.Add("PlayerSay", "ChatCommandSay", ChatCommandSay)

function PlayTheSound(ply, args)
	local Sound = Sound("weapons/mortar/mortar_shell_incomming1.wav") -- This is
the sound to play.

	ply:ConCommand("play " .. Sound)
	return ""
end
AddChatCommand("/playsound", PlayTheSound)

source: http://www.facepunch.com/threads/836201
History
Date User Action Args
2011-12-06 09:12:52matthiaskrgrsetmessageid: <1323162772.19.0.424355060369.issue553@freedroid.org>
2011-12-06 09:12:52matthiaskrgrlinkissue553 messages
2011-12-06 09:12:52matthiaskrgrcreate