private void checkServerOnline() { try { this._gameserver = new GameServerInfo.GameServer(ip, port, GameServerInfo.GameType.NeverwinterNights); this._gameserver.QueryServer(); if (this._gameserver.IsOnline) { string maxplayers = _gameserver.Parameters["maxplayers"]; string currentplayers = _gameserver.Parameters["numplayers"];; this.txtServerStatus.Text = "Online"; this.txtPlayers.Text = currentplayers + "/" + maxplayers; } else { this.txtServerStatus.Text = "Offline"; this.txtPlayers.Text = "N/A"; } } catch (Exception ex) { MessageBox.Show(ex.Message, "Server error", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
public ServerStatus(string ip, int port, MainForm form) { form.txtServerIP.Text = ip + ":" + port.ToString(); this._server = new GameServerInfo.GameServer(ip, port, GameServerInfo.GameType.NeverwinterNights); this._form = form; }
public static serverStatus checkServer(string serveraddress, string gametype, int serverport) { serverStatus returnValues = new serverStatus(); // query the selected server GameServerInfo.GameType type = (GameServerInfo.GameType)Enum.Parse(typeof(GameServerInfo.GameType), gametype.First().ToString().ToUpper() + gametype.Substring(1)); GameServerInfo.GameServer server = new GameServerInfo.GameServer(serveraddress, serverport, type); // Enable or disable debugmode (writes lastquery.dat to disk) server.DebugMode = false; var watch = System.Diagnostics.Stopwatch.StartNew(); server.QueryServer(); watch.Stop(); returnValues.scanTime = watch.ElapsedMilliseconds; var testD = server.Parameters["sv_maxclients"]; // Clear old stuff if (!server.IsOnline) { // Server is offline or not responding returnValues.serverOnline = false; return(returnValues); } else { returnValues.serverOnline = true; returnValues.playersConnected = server.NumPlayers; returnValues.maxPlayers = server.MaxPlayers; returnValues.serverName = server.Name; returnValues.serverMod = server.Mod; returnValues.serverMap = server.Map; returnValues.serverHasPassword = server.Passworded; // returnValues.serverType = server._type; return(returnValues); } }
private void checkServerOnline() { try { this._gameserver = new GameServerInfo.GameServer(ip, port, GameServerInfo.GameType.NeverwinterNights); this._gameserver.QueryServer(); if (this._gameserver.IsOnline) { string maxplayers = _gameserver.Parameters["maxplayers"]; string currentplayers = _gameserver.Parameters["numplayers"]; ; this.txtServerStatus.Text = "Online"; this.txtPlayers.Text = currentplayers + "/" + maxplayers; } else { this.txtServerStatus.Text = "Offline"; this.txtPlayers.Text = "N/A"; } } catch (Exception ex) { MessageBox.Show(ex.Message, "Server error", MessageBoxButtons.OK, MessageBoxIcon.Information); } }