private void btnKick_Click(object sender, EventArgs e) { string[] IP = txtConnection.Text.Split(':'); if (IsValidIPAddress(IP[0])) { Query.RCONQuery sQuery = new Query.RCONQuery(IP[0], Convert.ToInt32(IP[1]), txtPassword.Text); sQuery.Send("kick " + playerID[lstPlayers.SelectedIndex - 2]); lstRCON.Items.Clear(); int count = sQuery.Recieve(); lstRCON.Items.AddRange(sQuery.Store(count)); } else { MessageBox.Show("Invalid server IP"); } }
static void Main(string[] args) { Query.Query sQuery = new Query.Query("127.0.0.1", 7777); sQuery.Send('d'); int count = sQuery.Receive(); string[] info = sQuery.Store(count); foreach (string i in info) { Console.WriteLine(i); } Console.ReadKey(); /* * Variable 'info' might now contain: * Password Players Max. players Hostname Gamemode Language * { "0", "12", "500", "Query test server", "LVDM", "English" } */ //------------------------- Query.RCONQuery sRCONQuery = new Query.RCONQuery("127.0.0.1", 7777, "123"); sRCONQuery.Send("myriad"); count = sRCONQuery.Rceive(); string[] infoRCON = sQuery.Store(count); foreach (string i in infoRCON) { Console.WriteLine(i); } Console.ReadKey(); /* * Variable 'info' might now contain: * { "Hello from C#" } */ }
public void SendRCONQuery(string query, bool message = false) { string[] IP = txtConnection.Text.Split(':'); if (IsValidIPAddress(IP[0])) { Query.RCONQuery sQuery = new Query.RCONQuery(IP[0], Convert.ToInt32(IP[1]), txtPassword.Text); sQuery.Send(query); if (message == true) { lstRCON2.Items.Clear(); int count = sQuery.Recieve(); lstRCON2.Items.AddRange(sQuery.Store(count)); } } else { MessageBox.Show("Invalid server IP"); } }