All pastes #979748 Raw Edit

Unnamed

public text v1 · immutable
·published 2008-04-10 15:55 UTC
rendered paste body
vanityname = nil --A permanant name shown to other servers for your server. Set to nil to use your hostname.
ip = "64.251.15.233" --Only edit this if instructed to do so.
----------------------------------------------------
--Don't edit below here.
----------------------------------------------------
STARTED = false
function StartRendezvous()
	if STARTED == false then
		STARTED == true
		for k, v in pairs(player.GetAll()) do
			v:ChatPrint("Rendezvous is starting...")
		end
		require("socket")
		local conn = socket.connect(ip, 1702)
		conn:settimeout(0)
		conn:setoption("keepalive",true)
		if vanityname == nil then
			conn:send(GetConVarString("hostname").."\n")
			CURRHOST = GetConVarString("hostname")
		else
			conn:send(vanityname.."\n")
		end

		function SendMessage( ply, text, toall )
			conn:send(ply:Name()..": "..text.."\n")
		end
		function RecvMessage()
			local data = conn:receive("*l")
			if data ~= nil then
				for k, v in pairs(player.GetAll()) do
					v:ChatPrint(data)
				end
			end
		end
		function CheckHost()
			if(vanityname == nil) then	
				if GetConVarString("hostname") ~= CURRHOST then
					conn:send("HOST "..GetConVarString("hostname").."\n")
					CURRHOST = GetConVarString("hostname")
				end
			end
		end
		function Disconnect()
			conn:send("QUIT\n")
		end
		hook.Add("ShutDown", "Disconnect", Disconnect)  
		hook.Add("PlayerSay", "RendezvousSendMessage", SendMessage)
		timer.Create("RendezvousRecvMessage", 2, 0, RecvMessage)
		timer.Create("RendezvousCheckHost", 5, 0, CheckHost)
		for k, v in pairs(player.GetAll()) do
			v:ChatPrint("Rendezvous has started!")
		end
	end
end
hook.Add("Initialize", "StartRendezvous", StartRendezvous)