private void serverStatsToolStripMenuItem_Click(object sender, EventArgs e) { var res = WorkHelper.GetServerStats(ipToolStripTextBox.Text, portToolStripTextBox.Text, out var logText); logTextBox.Text += $"{logText}\r\n\r\n"; resultTextBox.Text += res + "\r\n"; }
public A2S_INFO(byte[] bs) { var i = WorkHelper.IndexOf(bs, 0x49); header = bs[i]; protocol = bs[i + 1]; name = Encoding.UTF8.GetString(WorkHelper.SubArray(bs, i + 2, WorkHelper.IndexOf(bs, 0x00, i + 2) - (i + 2))); i = WorkHelper.IndexOf(bs, 0x00, i + 2); map = Encoding.UTF8.GetString(WorkHelper.SubArray(bs, i + 1, WorkHelper.IndexOf(bs, 0x00, i + 1) - (i + 1))); i = WorkHelper.IndexOf(bs, 0x00, i + 1); folder = Encoding.UTF8.GetString(WorkHelper.SubArray(bs, i + 1, WorkHelper.IndexOf(bs, 0x00, i + 1) - (i + 1))); i = WorkHelper.IndexOf(bs, 0x00, i + 1); game = Encoding.UTF8.GetString(WorkHelper.SubArray(bs, i + 1, WorkHelper.IndexOf(bs, 0x00, i + 1) - (i + 1))); i = WorkHelper.IndexOf(bs, 0x00, i + 1); id = BitConverter.ToInt16(new byte[2] { bs[i + 1], bs[i + 2] }, 0); players = bs[i + 3]; max_players = bs[i + 4]; bots = bs[i + 5]; server_type = bs[i + 6]; environment = bs[i + 7]; visibility = bs[i + 8]; VAC = bs[i + 9]; }
private void serverAboutToolStripMenuItem_Click(object sender, EventArgs e) { var a2sInfo = WorkHelper.GetA2S_INFO(ipToolStripTextBox.Text, portToolStripTextBox.Text, out var logText); if (a2sInfo == null) { return; } resultTextBox.Text += a2sInfo.GetText() + "\r\n"; logTextBox.Text += $"{logText}\r\n\r\n"; }
private void checkServerPlayers_Tick(object sender, EventArgs e) { new Thread(() => { var a2sInfo = WorkHelper.GetA2S_INFO(ipToolStripTextBox.Text, portToolStripTextBox.Text, out var logText); if (a2sInfo == null) { return; } Invoke(new Action(() => { resultTextBox.Text += a2sInfo.GetText() + "\r\n"; logTextBox.Text += $"{logText}\r\n\r\n"; var n = 0; try { n = Convert.ToInt32(checkNToolStripTextBox.Text); } catch { } switch (typeCheckToolStripComboBox.SelectedIndex) { case 0: { if (a2sInfo.players < a2sInfo.max_players) { Console.Beep(5000, 300); } break; } case 1: { if (a2sInfo.players < a2sInfo.max_players - n) { Console.Beep(5000, 300); } break; } default: { if (a2sInfo.players < n) { Console.Beep(5000, 300); } break; } } })); }).Start(); }
private void serverStatsTimer_Tick(object sender, EventArgs e) { new Thread(() => { var res = WorkHelper.GetServerStats(ipToolStripTextBox.Text, portToolStripTextBox.Text, out _); if (res == "ERROR") { return; } var timeStr = res.Replace("\r", "").Split('\n').Single(str => str.Contains("CurrentServerTime")) .Split(':')[1]; var time = int.Parse(timeStr); var day = time / 24000 + 1; var hour = (time % 24000) / 1000; var mins = ((time % 1000) * 60) / 1000; if (hour == 6 || (hour == 5 && mins >= 40 && mins <= 60)) { Console.Beep(5000, 300); } Invoke(new Action(() => { resultTextBox.Text = $"{day} {hour} {mins}"; })); }).Start(); }