Esempio n. 1
0
 private void playerBackGround_DoWork(object sender, DoWorkEventArgs e)
 {
     while (!playerBackGround.CancellationPending)
     {
         for (int i = 1; i <= 100; i++)
         {
             Thread.Sleep(100);
             if (playerBackGround.CancellationPending)
             {
                 return;
             }
         }
         sr.ServerCommand(Properties.Settings.Default.Players);
         //Reset ChatBox
         PlayersTextBox.Invoke(
             (MethodInvoker)
             delegate
         {
             int count           = Regex.Matches(PlayersTextBox.Text, "(online)").Count;
             string pphole       = "Players (" + count + ")";
             tabPage3.Text       = pphole;
             PlayersTextBox.Text = "";
         }
             );
     }
 }
Esempio n. 2
0
        void sr_ServerOutput(MessageCode code, string data)
        {
            if (data.Contains("Players "))
            {
                int count1 = 0;
                int count2 = 1;
                //PlayersTextBox.Text = "";

                //this.PlayersTextBox.Text = "";
                //MessageBox.Show(data);
                string[] players = data.Split(' ');
                foreach (string i in players)
                {
                    //MessageBox.Show(i);
                    //System.Console.Write("{0} ", i);
                    string        testerv3 = (i);
                    MethodInvoker m        = () => { if (data != null)
                                                     {
                                                         PlayersTextBox.AppendText(testerv3);
                                                     }
                    };
                    this.Invoke(m);
                }

                if (WhitelistBox.Checked)
                {
                    //MessageBox.Show("Whitelist Enabled");
                    //whitelistWorker.RunWorkerAsync();
                    WhitelistText.Invoke(
                        (MethodInvoker)
                        delegate
                    {
                        foreach (string i in players)
                        {
                            //   count1 = count1 + 1;
                            //  count2 = count2 + 1;

                            //   string testing = players[count1] + players[count2];
                            // if (testing.Contains(i + "(online)"))
                            //{
                            //  MessageBox.Show("Yes");
                            //}

                            if (i.Contains("Players"))
                            {
                                //MessageBox.Show(i + " Is Safe ");
                            }
                            else if (i.Contains("(online)"))
                            //else if (WhitelistText.Text.Contains(i + "(online)"))
                            {
                                //MessageBox.Show(i + " Is Safe from containing online marker ");
                            }
                            else if (WhitelistText.Text.Contains(i))
                            //else if (WhitelistText.Contains(i))
                            {
                                //MessageBox.Show(i + " Is Safe from text box");
                            }
                            else if (whitelistban.Text.Contains(i))
                            {
                            }
                            else if (i.Contains(i + "(online)"))
                            {
                                MessageBox.Show("Senpai tell me how you got here");
                            }
                            else
                            {
                                sr.ServerCommand("/kick " + i + " You are not whitelisted on this server!");
                                string whitespace = (Environment.NewLine);
                                string whitelist  = (i);
                                MethodInvoker m   = () => { if (data != null)
                                                            {
                                                                whitelistban.AppendText(whitelist);
                                                            }
                                };
                                MethodInvoker w = () => { if (data != null)
                                                          {
                                                              whitelistban.AppendText(whitespace);
                                                          }
                                };
                                this.Invoke(w);
                                this.Invoke(m);
                            }
                        }
                    }
                        );

                    //
                }
            }
            else if (data.Contains("Player "))
            {
                //MessageBox.Show("I interuppted your console write");
            }
            else
            {
                MethodInvoker m = () => { if (data != null)
                                          {
                                              OutputBox.AppendText(data);
                                          }
                };
                this.Invoke(m);
            }
        }