All pastes #420282 Raw Edit

listen.lua

public text v1 · immutable
·published 2007-04-02 01:10 UTC
rendered paste body
listen = {}

listen.Active = {}

function listen.Add(sender, channel, arg)
	if table.haskey(listen.Active, arg) then return end
	listen.Active[arg] = channel
end

command.Add("listen", listen.Add, command.MSG, 5)

function listen.Remove(sender, channel, arg)
	listen.Active[arg] = nil
end

command.Add("stoplisten", listen.Remove, command.MSG, 5)

function listen.Listen(sender, channel, arg)
	for k,v in pairs(listen.Active) do
		if k == channel then
			sendMessage(v, "<"..sender..":"..channel.."> "..arg)
		end
	end
end

hook.Add(listen.Listen, hook.MSG, "listen.Listen")