public RconServers(string IP, int Port, string Password) { this.IP = IP; this.Port = Port; this.Password = Password; RconConnection = new SourceRcon(); }
static bool ConnectToRcon(SourceRcon Sr, string IP, int Port, string Pass) { if (Sr != null && !Sr.Connected) { int DotCount = 0; for (int i = 0; i < IP.Length; i++) { if (IP[i] == '.') { DotCount++; } } if (DotCount != 3) { IPAddress[] ips = Dns.GetHostAddresses(IP); if (ips.Length > 0) { IP = ips[0].ToString(); } } bool Connect = Sr.Connect(new IPEndPoint(IPAddress.Parse(IP), Port), Pass); int Counter = 0; while (!Sr.Connected) { Thread.Sleep(1000); if (Counter++ > 3) { return(false); } else if (Sr.Connected) { break; } } } return(true); }