コード例 #1
0
        private void btnSend_Click(object sender, EventArgs e)
        {
            // Try to make connection
            try
            {
                // Setup rcon connection
                RCON rcon = new RCON();

                // Tell the server that the bot is in it's init. state
                string response = rcon.sendCommand("say " + "\"^3Initializing j0rpi's WS Bot v0.4 ... [DONE]\"", textBox5.Text, textBox7.Text, Convert.ToInt32(textBox6.Text));
                textBox12.AppendText(response);
                timer1.Enabled  = true;
                timer1.Interval = Convert.ToInt32(textBox8.Text);

                // Disable this button (gray it out) and enable the stop button
                btnSend.Enabled = false;
                button1.Enabled = true;

                // Tell the user the connection succeeded
                label22.Text      = "Connected!";
                label22.ForeColor = Color.Green;
            }
            catch
            {
                // Instead of getting a ugly error form, we'll just tell the user connection failed.
                label22.Text      = "Connection Failed!";
                label22.ForeColor = Color.Red;
            }
        }
コード例 #2
0
        private void timer1_Tick_1(object sender, EventArgs e)
        {
            // Try to make a connection
            try
            {
                // Setup rcon connection
                RCON rcon = new RCON();

                // Send message 1
                string response = rcon.sendCommand("say " + "\"" + textBox1.Text + "\"", textBox5.Text, textBox7.Text, Convert.ToInt32(textBox6.Text));

                //replacing \n with \r\n so that it could be treated as enter in text area
                response = response.Replace("\n", "\r\n").Replace("????printRcon", "Rcon").Replace("????print", "").Replace("????print", "").Replace("????", "").Replace("print", "").Replace("????print", "").Replace("????print", "");
                textBox12.AppendText(response);
                timer1.Enabled  = false;
                timer2.Enabled  = true;
                timer2.Interval = Convert.ToInt32(textBox8.Text);

                // Tell the user the connection succeeded
                label22.Text      = "Connected!";
                label22.ForeColor = Color.Green;
            }
            catch
            {
                // Instead of getting a ugly error form, we'll just tell the user connection failed.
                label22.Text      = "Connection Failed!";
                label22.ForeColor = Color.Red;
            }
        }
コード例 #3
0
        private void timer4_Tick(object sender, EventArgs e)
        {
            // Try to make a connection
            try
            {
                // Setup rcon connection
                RCON rcon = new RCON();

                // Get connected players
                string response = rcon.sendCommand("status", textBox5.Text, textBox7.Text, Convert.ToInt32(textBox6.Text));

                //replacing \n with \r\n so that it could be treated as enter in text area
                response = response.Replace("\n", "\r\n").Replace("????printRcon", "Rcon").Replace("????print", "").Replace("????print", "").Replace("????", "").Replace("print", "").Replace("????print", "");
                textBox12.AppendText(response);

                // Tell the user the connection succeeded
                label22.Text      = "Connected!";
                label22.ForeColor = Color.Green;

                if (response.Contains(listBox1.Items.Count.ToString()))
                {
                    timer5.Start();
                }
            }
            catch
            {
                // Instead of getting a ugly error form, we'll just tell the user connection failed.
                label22.Text      = "Connection Failed!";
                label22.ForeColor = Color.Red;
            }
        }
コード例 #4
0
 private void button3_Click(object sender, EventArgs e)
 {
     try
     {
         if (textBox9.Text.Contains("rcon"))
         {
             MessageBox.Show("Please do not use 'rcon' like you would do in-game - This is done automaticly for you!", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
             textBox9.Text = "";
             label23.Text  = "Attempting RCON query ...";
         }
         else
         {
             // Setup rcon connection
             RCON   rcon     = new RCON();
             string response = rcon.sendCommand("\"" + textBox9.Text + "\"", "192.168.1.194", "kanelbulle", 44400).Replace("???print", "").Replace("?", "");
             response = response.Replace("\n", "\r\n");
             textBox12.AppendText(response);
             label23.Text = "Successfully Sent RCON Command!";
         }
     }
     catch (Exception)
     {
         label23.Text = "Failed to send command!";
     }
 }
コード例 #5
0
        private void btnSend_Click(object sender, EventArgs e)
        {
            RCON   rcon     = new RCON();
            string response = rcon.sendCommand(txtCommand.Text, txtGameServerIP.Text, "123456", 12203);

            //replacing \n with \r\n so that it could be treated as enter in text area
            response         = response.Replace("\n", "\r\n");
            txtResponse.Text = response;
        }
コード例 #6
0
        private void timer2_Tick_1(object sender, EventArgs e)
        {
            // Ugly way of making modifiers for text messages ...

            if (textBox2.Text.Contains("%time%"))
            {
                modifierval = "%time%";
                variable    = DateTime.Now.ToString("HH:mm:ss", System.Globalization.DateTimeFormatInfo.InvariantInfo) + " (Server Time)";
            }

            if (textBox2.Text.Contains("%botversion%"))
            {
                modifierval = "%botversion%";
                variable    = "j0rpiWSBot 0.5";
            }



            // Try to make a connection
            try
            {
                // Setup rcon connection
                RCON rcon = new RCON();

                // Send message 2
                string response = rcon.sendCommand("say " + "\"" + textBox2.Text.ToString().Replace(modifierval, variable) + "\"", textBox5.Text, textBox7.Text, Convert.ToInt32(textBox6.Text));

                //replacing \n with \r\n so that it could be treated as enter in text area
                response = response.Replace("\n", "\r\n").Replace("????printRcon", "Rcon").Replace("????print", "").Replace("????print", "").Replace("????", "").Replace("print", "").Replace("????print", "");
                textBox12.AppendText(response);
                timer2.Enabled  = false;
                timer3.Enabled  = true;
                timer3.Interval = Convert.ToInt32(textBox8.Text);

                // Tell the user the connection succeeded
                label22.Text      = "Connected!";
                label22.ForeColor = Color.Green;
            }
            catch
            {
                // Instead of getting a ugly error form, we'll just tell the user connection failed.
                label22.Text      = "Connection Failed!";
                label22.ForeColor = Color.Red;
            }
        }
コード例 #7
0
        private void timer5_Tick(object sender, EventArgs e)
        {
            // Try to make a connection
            try
            {
                // Setup rcon connection
                RCON rcon = new RCON();


                // Get connected players
                string response = rcon.sendCommand("status", textBox5.Text, textBox7.Text, Convert.ToInt32(textBox6.Text));

                //replacing \n with \r\n so that it could be treated as enter in text area
                response = response.Replace("\n", "\r\n").Replace("????printRcon", "Rcon").Replace("????print", "").Replace("????print", "").Replace("????", "").Replace("print", "").Replace("????print", "");
                textBox12.AppendText(response);
                // Tell the user the connection succeeded
                label22.Text      = "Connected!";
                label22.ForeColor = Color.Green;
                if (response.Contains("j0rpi"))
                {
                    rcon.sendCommand("say " + "\"" + textBox10.Text + textBox11.Text + " j0rpi" + "\"", textBox5.Text, textBox7.Text, Convert.ToInt32(textBox6.Text));
                    timer5.Interval = 180000;
                }
                else if (response.Contains("j0rpi h0tt0w"))
                {
                    rcon.sendCommand("say " + "\"" + textBox10.Text + textBox11.Text + " j0rpi, h0tt0w" + "\"", textBox5.Text, textBox7.Text, Convert.ToInt32(textBox6.Text));
                    timer5.Interval = 180000;
                }
                else if (response.Contains("h0tt0w"))
                {
                    rcon.sendCommand("say " + "\"" + textBox10.Text + textBox11.Text + " h0tt0w" + "\"", textBox5.Text, textBox7.Text, Convert.ToInt32(textBox6.Text));
                    timer5.Interval = 180000;
                }
                else
                {
                    // Do nothing...
                }
            }
            catch
            {
                // Instead of getting a ugly error form, we'll just tell the user connection failed.
                label22.Text      = "Connection Failed!";
                label22.ForeColor = Color.Red;
            }
        }
コード例 #8
0
        private void timer7_Tick(object sender, EventArgs e)
        {
            // Try to make a connection
            try
            {
                // Setup rcon connection
                RCON rcon = new RCON();

                // Get connected players

                string response = rcon.sendCommand("status", textBox5.Text, textBox7.Text, Convert.ToInt32(textBox6.Text));

                // Ugly and messy - Check if the response contains j0rpi, h0tt0w, or both
                if (response.Contains("j0rpi"))
                {
                    rcon.sendCommand("say " + "\"" + textBox10.Text + textBox11.Text + " j0rpi" + "\"", textBox5.Text, textBox7.Text, Convert.ToInt32(textBox6.Text));
                    timer7.Enabled = false;
                }
                else if (response.Contains("h0tt0w"))
                {
                    rcon.sendCommand("say " + "\"" + textBox10.Text + textBox11.Text + " h0tt0w" + "\"", textBox5.Text, textBox7.Text, Convert.ToInt32(textBox6.Text));
                    timer7.Enabled = false;
                }
                else if (response.Contains("j0rpi") && (response.Contains("h0tt0w")))
                {
                    rcon.sendCommand("say " + "\"" + textBox10.Text + textBox11.Text + " j0rpi / h0tt0w" + "\"", textBox5.Text, textBox7.Text, Convert.ToInt32(textBox6.Text));
                    timer7.Enabled = false;
                }
                else
                {
                    // Do nothin'
                }
            }
            catch
            {
                // Instead of getting a ugly error form, we'll just tell the user connection failed.
                label22.Text      = "Connection Failed!";
                label22.ForeColor = Color.Red;
            }
        }
コード例 #9
0
        private void btnSend_Click_1(object sender, EventArgs e)
        {
            label22.Text = "Connecting ...";
            // Try to make a connection
            try
            {
                // Tell the server that the bot is in it's init. state
                RCON rcon = new RCON();

                rcon.sendCommand("say " + "\"^3Initializing j0rpi's WS Bot v0.5 ... [DONE]\"", "127.0.0.1", "kanelbulle", 44400);
                timer1.Enabled  = true;
                timer1.Interval = Convert.ToInt32(textBox8.Text);

                // Disable this button (gray it out) and enable the stop button
                btnSend.Enabled = false;
                button1.Enabled = true;

                // Tell the user the connection succeeded
                label22.Text      = "Connected!";
                label22.ForeColor = Color.Green;

                // Change Form Title
                this.Text  = "j0rpi's WS Bot v0.5";
                this.Text += " - Connected to" + textBox5.Text;

                // Disable IP/PORT/PW/ textboxes
                textBox5.Enabled  = false;
                textBox6.Enabled  = false;
                textBox7.Enabled  = false;
                comboBox1.Enabled = false;
            }
            catch
            {
                // Instead of getting a ugly error form, we'll just tell the user connection failed.
                label22.Text      = "Connection Failed!";
                label22.ForeColor = Color.Red;
            }
        }