def a2s_info(addr, port)
socket = UDPSocket.new()
- socket.send(A2S_INFO, 0, addr, port.to_i)
- response = nil
-
begin
+ socket.send(A2S_INFO, 0, addr, port.to_i)
+ response = nil
+
timeout(TIMEOUT) do
response = socket.recvfrom(1400,0)
end
- rescue Exception
+ rescue Exception => e
+ error e
end
socket.close()
def hl2(m, params)
addr, port = params[:conn_str].split(':')
info = a2s_info(addr, port)
- if info != nil
+ if info
m.reply "#{info[3]} is online with #{info[8]}/#{info[9]} players."
else
m.reply "Couldn't connect to #{params[:conn_str]}"