Official Everybody Edits Forums

Do you think I could just leave this part blank and it'd be okay? We're just going to replace the whole thing with a header image anyway, right?

You are not logged in.

#1 2015-02-26 08:20:16, last edited by Psychocrysma (2015-02-26 13:37:58)

Psychocrysma
Member
Joined: 2015-02-26
Posts: 46

Listbox&Listview problem with userdata

Hello guys, so I'm quite new to Everbody Edits bots programming. I am used to C#, but not on anything that is online. That said, I've been having this error in debug mode and I have noticed, through everything I have tried, that it causes many problems. The error comes up every time there is interaction with a list and this stops every code after the error. So, for the admin list, the application verify with who the ID of the sender (the person who talked) match in the user list and verify if this user is the admin list. What happens: there's an error when there's interaction with the list, so every code after that won't work, making it quite useless...

Here's the error and its translation made by myself:
"Une exception de type 'System.InvalidOperationException' s'est produite dans System.Windows.Forms.dll mais n'a pas été gérée dans le code utilisateur

Informations supplémentaires : Opération inter-threads non valide : le contrôle 'usrList' a fait l'objet d'un accès à partir d'un thread autre que celui sur lequel il a été créé."

"An exception of type 'System.InvalidOperationException' happened in System.Windows.Forms.dll, but didn't get managed in the user code.

More information: Operation inter-threads invalid : the control 'usrList' was accessed from a thread other than the one it was created on."

So, to be honest, I'm not sure how to deal with this, so here's my code and an image of my application.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using PlayerIOClient;
using System.IO;
using System.Diagnostics;
using System.Threading;

namespace Yin_Yang_War
{
    public partial class Form1 : Form
    {
        #region Variables
        public Connection conn;
        public Client client;
        public List<string> names = new List<string>();
        public List<string> ids = new List<string>();
        public Random ran = new Random();
        public string worldKey;
        string adminPath = System.Environment.CurrentDirectory + "\\Admin.txt";
        string banPath = System.Environment.CurrentDirectory + "\\Ban.txt";
        string pointPath = System.Environment.CurrentDirectory + "\\Points.txt";
        public int timer = 0;
        int interval = 10;
        bool antibug = true;
        #endregion
        public Form1()
        {
            InitializeComponent();
        }

        public void conBut_Click(object sender, EventArgs e)
        {
            client = PlayerIO.QuickConnect.SimpleConnect("everybody-edits-su9rn58o40itdbnw69plyw", "Flapjacks r kewl", "I eat bees for fun", null);
            conn = client.Multiplayer.JoinRoom("PWY_Aq3Hkob0I", null);
            conn.OnMessage += OnMessage;
            conn.Send("init");

            if (File.Exists(adminPath))
            {
                try
                {
                    using (StreamReader reader = new StreamReader(adminPath))
                    {
                        string line;
                        while ((line = reader.ReadLine()) != null)
                        {
                            adList.Items.Add(line);
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message.ToString(), "Error");
                }
            }
            if (File.Exists(banPath))
            {
                try
                {
                    using (StreamReader reader = new StreamReader(banPath))
                    {
                        string line;
                        while ((line = reader.ReadLine()) != null)
                        {
                            banList.Items.Add(line);
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message.ToString(), "Error");
                }
            }

            if (File.Exists(pointPath))
            {
                try
                {
                    using (StreamReader reader = new StreamReader(pointPath))
                    {
                        string line;
                        int count = 0;
                        while ((line = reader.ReadLine()) != null)
                        {
                            count++;
                            if (count == 1)
                            {
                                lightLabel.Text = line.ToString();
                            }
                            if (count == 2)
                            {
                                darkLabel.Text = line.ToString();
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message.ToString(), "Error");
                }
            }
            disconnect.Enabled = true;
            conBut.Enabled = false;
            timer2.Enabled = true;
        }

        public void OnMessage(object sender, PlayerIOClient.Message m)
        {
            if (m.Type == "init")
            {
                conn.Send("init2");
                conn.Send("god", true);
                worldKey = Rot13(m.GetString(5));
                conn.Send(worldKey + "f", 12);
                conn.Send("say", "[BOT] Connected!");
                conn.Send("m", 1, 1, 1, 1, 2, 2, 0, 0);
            }

            if (m.Type == "add")
            {
                BanListKick(m[1].ToString());
                AdminListGive(m[1].ToString());
                ListViewItem user = new ListViewItem(m[1].ToString().ToUpper());
                user.SubItems.Add(m[0].ToString());
                usrList.Items.Add(user);
            }
            
            if (m.Type == "left")
            {
                usrList.Items.Remove(usrList.FindItemWithText(m[0].ToString()));
            }

            if (m.Type == "say")
            {
                bool adminAuth = false;
                ListViewItem userAuth = usrList.FindItemWithText(m[0].ToString());
                AdminAuthChat(userAuth.Text, adminAuth);
                conn.Send("say", "User is " + userAuth.Text + " and ID is " + m[0].ToString());
                Thread.Sleep(2000);
                conn.Send("say", "Got through here");
                if (m[1].ToString().Trim() == "!amiadmin" && adminAuth == true)
                {
                    Thread.Sleep(2000);
                    conn.Send("say", "Indeed you are");
                }
                if (m[1].ToString().ToLower() == "!restart" && adminAuth == true)
                {
                    conn.Send("say", "[BOT] Made it");
                    timer1.Enabled = false;
                    conn.Send("say", "/reset");
                    Thread.Sleep(1000);
                    timer = 0;
                    timer1.Enabled = true;
                }
                if (m[1].ToString().Contains("!addadmin") == true && adminAuth == true)
                {
                    conn.Send("say", "Passed here");
                    Thread.Sleep(1000);
                    adList.Items.Add(m[1].ToString().ToUpper().Replace("!addadmin ", ""));
                }
                if (m[1].ToString().ToUpper().StartsWith("!REMADMIN ") == true && adminAuth == true)
                {
                    try
                    {
                        adList.Items.Remove(m[1].ToString().ToUpper().Replace("!REMADMIN ", ""));
                    }
                    catch
                    {
                        conn.Send("say", "[BOT] User does not exist.");
                    }
                }
                if (m[1].ToString().ToUpper().StartsWith("!BAN ") == true && adminAuth == true)
                {
                    banList.Items.Add(m[1].ToString().ToUpper().Replace("!BAN ", ""));
                }
                if (m[1].ToString().ToUpper().StartsWith("!REMBAN ") == true && adminAuth == true)
                {
                    try
                    {
                        banList.Items.Remove(m[1].ToString().ToUpper().Replace("!REMBAN ", ""));
                    }
                    catch
                    {
                        conn.Send("say", "[BOT] User does not exist.");
                    }
                }
            }
            if (m.Type == "c")
            {
                if (antibug == false)
                {
                    ListViewItem player = usrList.FindItemWithText(m[0].ToString());
                    int addPoint = int.Parse(lightLabel.Text);
                    addPoint++;
                    lightLabel.Text = addPoint.ToString();
                    conn.Send("say", player.Text + " has found the heavenly coin!");
                    Thread.Sleep(1000);
                    conn.Send("say", "The Light side won!");
                    Thread.Sleep(1000);
                    conn.Send("say", "/reset");
                    timer = 0;
                    timer1.Enabled = true;
                }
            }

            if (m.Type == "k")
            {
                if (antibug == false)
                {
                    ListViewItem player = usrList.FindItemWithText(m[0].ToString());
                    int addPoint = int.Parse(darkLabel.Text);
                    addPoint++;
                    darkLabel.Text = addPoint.ToString();
                    conn.Send("say", player.Text + " has found the cursed crown!");
                    conn.Send("say", "The Dark side won!");
                    conn.Send("say", "/reset");
                    timer = 0;
                    timer1.Enabled = true;
                }
            }
        }

        public void BanListKick(string username)
        {
            int index = banList.FindString(username, -1);
            if (index != -1)
            {
                conn.Send("say", "/kick " + username);
            }
        }

        public void AdminListGive(string username)
        {
            int index = adList.FindString(username, -1);
            if (index != -1)
            {
                conn.Send("say", "/giveedit " + username);
            }
        }

        public void AdminAuthChat(string username, bool auth)
        {
            int index = adList.FindString(username, -1);
            if (index != -1)
            {
                auth = true;
                conn.Send("say", "Came by the Authentification Aanlyzer");
            }
        }

        public string Rot13(string arg1)
        {
            int num = 0;
            string str = "";
            for (int i = 0; i < arg1.Length; i++)
            {
                num = arg1[i];
                if ((num >= 0x61) && (num <= 0x7a))
                {
                    if (num > 0x6d) num -= 13;
                    else num += 13;
                }
                else if ((num >= 0x41) && (num <= 90))
                {
                    if (num > 0x4d) num -= 13;
                    else num += 13;
                }
                str = str + ((char)num);
            }
            return str;
        }

        public void browseF_Click(object sender, EventArgs e)
        {
            Process.Start(System.Environment.CurrentDirectory);
        }

        public void disconnect_Click(object sender, EventArgs e)
        {
            Disconnect();
            conBut.Enabled = true;
        }

        public void Disconnect()
        {
            conn.Disconnect();
            using (StreamWriter writer = new StreamWriter(adminPath))
            {
                int count = 0;
                foreach (var item in adList.Items)
                {
                    if (count == 0)
                    {
                        writer.Write(item.ToString());
                        count++;
                    }
                    else
                    {
                        writer.WriteLine(item.ToString());
                    }
                }
            }
            using (StreamWriter writer = new StreamWriter(banPath))
            {
                int count = 0;
                foreach (var item in banList.Items)
                {
                    if (count == 0)
                    {
                        writer.Write(item.ToString());
                        count++;
                    }
                    else
                    {
                        writer.WriteLine(item.ToString());
                    }
                }
            }
            using (StreamWriter writer = new StreamWriter(pointPath))
            {
                writer.WriteLine(lightLabel.Text);
                writer.WriteLine(darkLabel.Text);
            }
            disconnect.Enabled = false;
        }

        public void timer1_Tick(object sender, EventArgs e)
        {
            Thread.Sleep(1000);
            conn.Send("say", "Timer enabled");
            if (timer == interval)
            {
                Thread.Sleep(1000);
                conn.Send("say", "Timer deactivated. Key function");
                timer1.Enabled = false;
                timer = 0;
                Random random = new Random();
                int randomPathKey = random.Next(0, 7);
                if (randomPathKey == 0)
                {
                    conn.Send(worldKey + "r");
                }
                if (randomPathKey == 1)
                {
                    conn.Send(worldKey + "g");
                }
                if (randomPathKey == 2)
                {
                    conn.Send(worldKey + "b");
                }
                if (randomPathKey == 3)
                {
                    conn.Send(worldKey + "c");
                }
                if (randomPathKey == 4)
                {
                    conn.Send(worldKey + "m");
                }
                if (randomPathKey == 5)
                {
                    conn.Send(worldKey + "y");
                }
                if (randomPathKey == 6)
                {
                    Thread.Sleep(1000);
                    conn.Send("say", "None");
                }
            }
        }

        public void timer2_Tick(object sender, EventArgs e)
        {
            timer2.Enabled = false;
            antibug = false;
        }
    }
}

1WaMyN7.png

Offline

#2 2015-02-26 10:48:09

Koya
Fabulous Member
From: The island with those Brits
Joined: 2015-02-18
Posts: 6,310

Re: Listbox&Listview problem with userdata

I don't quite understand what you mean, but you should edit the part out where you log in (your details are visible)


Po9cnQh.png

PLNQVL8.png
Thank you eleizibeth ^

1SYOldu.png

I stack my signatures rather than delete them so I don't lose them
giphy.gif

WfSi4mm.png

Offline

#3 2015-02-26 12:09:27

ewoke
Member
Joined: 2015-02-20
Posts: 412

Re: Listbox&Listview problem with userdata

pssssst u might wnat to remove your email and pass from the source


if you can read this....good for you

Offline

#4 2015-02-26 13:10:48

Different55
Forum Admin
Joined: 2015-02-07
Posts: 16,574

Re: Listbox&Listview problem with userdata

User/pass have been removed.


"Sometimes failing a leap of faith is better than inching forward"
- ShinsukeIto

Offline

#5 2015-02-26 13:33:19, last edited by Zoey2070 (2015-02-26 22:49:45)

Psychocrysma
Member
Joined: 2015-02-26
Posts: 46

Re: Listbox&Listview problem with userdata

Koya wrote:

I don't quite understand what you mean, but you should edit the part out where you log in (your details are visible)

Holy crap. Thanks for telling me. I wrote that at 3 AM and I can be quite stupid when I'm tired~

Offline

#6 2015-02-26 13:34:45, last edited by Psychocrysma (2015-02-26 13:38:47)

Psychocrysma
Member
Joined: 2015-02-26
Posts: 46

Re: Listbox&Listview problem with userdata

The problem is, every time there is interaction with a list, the error comes up and it stops every code coming next. Also, edited the original post with more information. I will probably add where there's errors in the code when I have time later today.

Offline

#7 2015-02-26 14:18:42

Koya
Fabulous Member
From: The island with those Brits
Joined: 2015-02-18
Posts: 6,310

Re: Listbox&Listview problem with userdata

Psychocrysma wrote:

The problem is, every time there is interaction with a list, the error comes up and it stops every code coming next. Also, edited the original post with more information. I will probably add where there's errors in the code when I have time later today.

So, if you were to click on an item in the list there will be an error?


Po9cnQh.png

PLNQVL8.png
Thank you eleizibeth ^

1SYOldu.png

I stack my signatures rather than delete them so I don't lose them
giphy.gif

WfSi4mm.png

Offline

#8 2015-02-26 14:48:16

Xfrogman43
Member
From: need to find a new home
Joined: 2015-02-15
Posts: 4,174

Re: Listbox&Listview problem with userdata

This should go but some people say it is bad

public Form1()
        {
            CheckForIllegalCrossThreadCalls = false; // THIS PUT THIS HERE
            InitializeComponent();
        }

zsbu6Xm.png thanks zoey aaaaaaaaaaaand thanks latif for the avatar

Offline

#9 2015-02-26 15:24:30

ZeldaXD
EE Homeboy
From: Cyprus
Joined: 2015-02-15
Posts: 1,539
Website

Re: Listbox&Listview problem with userdata

Psychocrysma wrote:
Koya wrote:

I don't quite understand what you mean, but you should edit the part out where you log in (your details are visible)

Holy ****. Thanks for telling me. I wrote that at 3 AM and I can be quite stupid when I'm tired~

I would recommend you to change your password.


gLjTZE1.png

Offline

#10 2015-02-26 23:14:18

Psychocrysma
Member
Joined: 2015-02-26
Posts: 46

Re: Listbox&Listview problem with userdata

Xfrogman43 wrote:

This should go but some people say it is bad

public Form1()
        {
            CheckForIllegalCrossThreadCalls = false; // THIS PUT THIS HERE
            InitializeComponent();
        }

But I have read on Buzzerbee's post that it shouldn't be done. I didn't get how to use his Invoke thing though.
/viewtopic.php?id=11626

Offline

#11 2015-02-27 00:08:51

Xfrogman43
Member
From: need to find a new home
Joined: 2015-02-15
Posts: 4,174

Re: Listbox&Listview problem with userdata

Psychocrysma wrote:
Xfrogman43 wrote:

This should go but some people say it is bad

public Form1()
        {
            CheckForIllegalCrossThreadCalls = false; // THIS PUT THIS HERE
            InitializeComponent();
        }

But I have read on Buzzerbee's post that it shouldn't be done. I didn't get how to use his Invoke thing though.
/viewtopic.php?id=11626

I guess something like this:

 private void bu_LOGIN_Click(object sender, EventArgs e)
        {
          //login stuff
                this.Invoke((MethodInvoker)delegate
                {
                    bu_LOGIN.Text = "Disconnect";
                });
         }

zsbu6Xm.png thanks zoey aaaaaaaaaaaand thanks latif for the avatar

Offline

#12 2015-02-27 00:42:42, last edited by Psychocrysma (2015-02-27 00:45:17)

Psychocrysma
Member
Joined: 2015-02-26
Posts: 46

Re: Listbox&Listview problem with userdata

Xfrogman43 wrote:

This should go but some people say it is bad

public Form1()
        {
            CheckForIllegalCrossThreadCalls = false; // THIS PUT THIS HERE
            InitializeComponent();
        }

I seem to have many weird problems. Maybe I should have used one of those simplified libraries... Anyway, I'm going to try something for this new-found problem and, if I can't find a way to work it out, I'll post tomorrow. It seems to be related to the items. It's as if the items are seen as empty, which causes a NullException error thing. It always does it when I try to get the text from it.

From what I can see, the problem might be the following:
To get the usernames from the IDs, I'm using a Listview, but the IDs are in the second column, which means it is SubItems[1]. That said, I'm using:
ListViewItem item = new ListViewItem();
item = usrList.FindItemWithString(ID);
The error happens in the "item = usrList.FindItemWithString(ID);".
This line is supposed to get the Username (item.SubItems[0].Text) that is associated with the received ID.
What I'm wondering is, does the FindItemWithString method scan the SubItems as well? If it doesn't, then there might be the problem. Anyway, I might try reverting these tomorrow, but if I can get a confirmation or something, that'd be helpful.

Offline

#13 2015-02-27 01:22:35, last edited by Xfrogman43 (2015-02-27 01:23:00)

Xfrogman43
Member
From: need to find a new home
Joined: 2015-02-15
Posts: 4,174

Re: Listbox&Listview problem with userdata

 if (m.Type == "left")
            {
                usrList.Items.Remove(usrList.FindItemWithText(m[0].ToString()));
            }

This?
Just do
//at top

                                 ListViewItem item = new ListViewItem();
"add"
                                item.Text = m.GetString(1);
                                item.SubItems.Add(Convert.ToString(m.GetInt(0)));
                                lv_USERS.Items.Add(item);
                            }
"left"
lv_USERS.Items.Remove(item);

Should do this:
i68ea.gifvia Imgflip GIF Maker


zsbu6Xm.png thanks zoey aaaaaaaaaaaand thanks latif for the avatar

Offline

#14 2015-02-27 13:19:49, last edited by Processor (2015-02-27 19:13:23)

Psychocrysma
Member
Joined: 2015-02-26
Posts: 46

Re: Listbox&Listview problem with userdata

Xfrogman43 wrote:
 if (m.Type == "left")
            {
                usrList.Items.Remove(usrList.FindItemWithText(m[0].ToString()));
            }

This?
Just do
//at top

                                 ListViewItem item = new ListViewItem();
"add"
                                item.Text = m.GetString(1);
                                item.SubItems.Add(Convert.ToString(m.GetInt(0)));
                                lv_USERS.Items.Add(item);
                            }
"left"
lv_USERS.Items.Remove(item);

Still doesn't seem to be working. The problem seem to be in the list again, but it's now in the "say" side. NullReferenceException again. I will put // where it is Here's my code at the moment:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using PlayerIOClient;
using System.IO;
using System.Diagnostics;
using System.Threading;

namespace Yin_Yang_War
{
    public partial class Form1 : Form
    {
        #region Variables
        public Connection conn;
        public Client client;
        public List<string> names = new List<string>();
        public List<string> ids = new List<string>();
        public Random ran = new Random();
        public string worldKey;
        string adminPath = System.Environment.CurrentDirectory + "\\Admin.txt";
        string banPath = System.Environment.CurrentDirectory + "\\Ban.txt";
        string pointPath = System.Environment.CurrentDirectory + "\\Points.txt";
        public int timer = 0;
        int interval = 10;
        bool antibug = true;
        #endregion
        public Form1()
        {
            CheckForIllegalCrossThreadCalls = false;
            InitializeComponent();
        }

        public void conBut_Click(object sender, EventArgs e)
        {
            client = PlayerIO.QuickConnect.SimpleConnect("everybody-edits-su9rn58o40itdbnw69plyw", <snip>, <snip>, null);
            conn = client.Multiplayer.JoinRoom("PWY_Aq3Hkob0I", null);
            conn.OnMessage += OnMessage;
            conn.Send("init");

            if (File.Exists(adminPath))
            {
                try
                {
                    using (StreamReader reader = new StreamReader(adminPath))
                    {
                        string line;
                        while ((line = reader.ReadLine()) != null)
                        {
                            ListViewItem item = new ListViewItem(line);
                            adList.Items.Add(item);
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message.ToString(), "Error");
                }
            }
            if (File.Exists(banPath))
            {
                try
                {
                    using (StreamReader reader = new StreamReader(banPath))
                    {
                        string line;
                        while ((line = reader.ReadLine()) != null)
                        {
                            ListViewItem item = new ListViewItem(line);
                            banList.Items.Add(item);
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message.ToString(), "Error");
                }
            }

            if (File.Exists(pointPath))
            {
                try
                {
                    using (StreamReader reader = new StreamReader(pointPath))
                    {
                        string line;
                        int count = 0;
                        while ((line = reader.ReadLine()) != null)
                        {
                            count++;
                            if (count == 1)
                            {
                                lightLabel.Text = line.ToString();
                            }
                            if (count == 2)
                            {
                                darkLabel.Text = line.ToString();
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message.ToString(), "Error");
                }
            }
            disconnect.Enabled = true;
            conBut.Enabled = false;
            timer2.Enabled = true;
        }

        public void OnMessage(object sender, PlayerIOClient.Message m)
        {
            if (m.Type == "init")
            {
                conn.Send("init2");
                conn.Send("god", true);
                worldKey = Rot13(m.GetString(5));
                conn.Send(worldKey + "f", 12);
                conn.Send("say", "[BOT] Connected!");
            }
            ListViewItem item = new ListViewItem();
            if (m.Type == "add")
            {
                item = banList.FindItemWithText(m.GetString(1));
                Thread.Sleep(2000);

                if (item.Text == m.GetString(1))
                {
                    conn.Send("say", "/kick " + m.GetString(1));
                }
                item = adList.FindItemWithText(m.GetString(1));
                if (item.Text == m.GetString(1))
                {
                    conn.Send("say", "/giveedit " + m.GetString(1));
                }
                ListViewItem user = new ListViewItem(Convert.ToString(m.GetInt(0)));
                user.SubItems.Add(m.GetString(1));
                usrList.Items.Add(user);
            }
            
            if (m.Type == "left")
            {
                usrList.Items.Remove(item);
            }

            if (m.Type == "say")
            {
                bool adminAuth = false;
                //try
                //{
                    ListViewItem userAuth = usrList.FindItemWithText(Convert.ToString(m.GetInt(0)));
                    if (userAuth.SubItems[1].Text.ToString() != null) //Exception is right here. NullReferenceException
                    {
                        ListViewItem adItem = new ListViewItem();
                        adItem = adList.FindItemWithText(userAuth.SubItems[1].Text.ToString());
                        if (userAuth.SubItems[1].Text.ToString() == adItem.Text)
                        {
                            adminAuth = true;
                            conn.Send("say", "Came by the Authentification Aanlyzer");
                            if (adminAuth == true)
                            {
                                Thread.Sleep(5000);
                            }
                        }
                    }
                    conn.Send("say", "User is " + userAuth.Text + " and ID is " + Convert.ToString(m.GetInt(0)));
                //}
                /*catch (Exception ex)
                {
                    MessageBox.Show(ex.Message.ToString(), "Error");
                }*/
                if (m.GetString(1).Trim() == "!amiadmin" && adminAuth == true)
                {
                    conn.Send("say", "Indeed you are");
                }
                if (m.GetString(1).ToLower() == "!restart" && adminAuth == true)
                {
                    conn.Send("say", "[BOT] Made it");
                    timer1.Enabled = false;
                    conn.Send("say", "/reset");
                    Thread.Sleep(1000);
                    timer = 0;
                    timer1.Enabled = true;
                }
                if (m.GetString(1).StartsWith("!addadmin") == true && adminAuth == true)
                {
                    conn.Send("say", "Passed here");
                    Thread.Sleep(1000);
                    adList.Items.Add(m.GetString(1).ToUpper().Replace("!addadmin ", ""));
                }
                if (m.GetString(1).ToUpper().StartsWith("!REMADMIN ") == true && adminAuth == true)
                {
                    try
                    {
                        adList.Items.Remove(adList.FindItemWithText(m.GetString(1).ToUpper().Replace("!REMADMIN ", "")));
                    }
                    catch
                    {
                        conn.Send("say", "[BOT] User does not exist.");
                    }
                }
                if (m.GetString(1).ToUpper().StartsWith("!BAN ") == true && adminAuth == true)
                {
                    banList.Items.Add(m.GetString(1).ToUpper().Replace("!BAN ", ""));
                }
                if (m.GetString(1).ToUpper().StartsWith("!REMBAN ") == true && adminAuth == true)
                {
                    try
                    {
                        banList.Items.Remove(banList.FindItemWithText(m.GetString(1).ToUpper().Replace("!REMBAN ", "")));
                    }
                    catch
                    {
                        conn.Send("say", "[BOT] User does not exist.");
                    }
                }
            }
            if (m.Type == "c")
            {
                if (antibug == false)
                {
                    ListViewItem player = usrList.FindItemWithText(Convert.ToString(m.GetInt(0)));
                    int addPoint = int.Parse(lightLabel.Text);
                    addPoint++;
                    lightLabel.Text = addPoint.ToString();
                    conn.Send("say", player.Text + " has found the heavenly coin!");
                    Thread.Sleep(1000);
                    conn.Send("say", "The Light side won!");
                    Thread.Sleep(1000);
                    conn.Send("say", "/reset");
                    timer = 0;
                    timer1.Enabled = true;
                }
            }

            if (m.Type == "k")
            {
                if (antibug == false)
                {
                    ListViewItem player = usrList.FindItemWithText(Convert.ToString(m.GetInt(0)));
                    int addPoint = int.Parse(darkLabel.Text);
                    addPoint++;
                    darkLabel.Text = addPoint.ToString();
                    conn.Send("say", player.Text + " has found the cursed crown!");
                    conn.Send("say", "The Dark side won!");
                    conn.Send("say", "/reset");
                    timer = 0;
                    timer1.Enabled = true;
                }
            }
        }

        public string Rot13(string arg1)
        {
            int num = 0;
            string str = "";
            for (int i = 0; i < arg1.Length; i++)
            {
                num = arg1[i];
                if ((num >= 0x61) && (num <= 0x7a))
                {
                    if (num > 0x6d) num -= 13;
                    else num += 13;
                }
                else if ((num >= 0x41) && (num <= 90))
                {
                    if (num > 0x4d) num -= 13;
                    else num += 13;
                }
                str = str + ((char)num);
            }
            return str;
        }

        public void browseF_Click(object sender, EventArgs e)
        {
            Process.Start(System.Environment.CurrentDirectory);
        }

        public void disconnect_Click(object sender, EventArgs e)
        {
            Disconnect();
            conBut.Enabled = true;
        }

        public void Disconnect()
        {
            conn.Disconnect();
            using (StreamWriter writer = new StreamWriter(adminPath))
            {
                int count = 0;
                foreach (ListViewItem item in adList.Items)
                {
                    if (count == 0)
                    {
                        writer.Write(item.Text);
                        count++;
                    }
                    else
                    {
                        writer.WriteLine(item.Text);
                    }
                }
            }
            using (StreamWriter writer = new StreamWriter(banPath))
            {
                int count = 0;
                foreach (ListViewItem item in banList.Items)
                {
                    if (count == 0)
                    {
                        writer.Write(item.Text);
                        count++;
                    }
                    else
                    {
                        writer.WriteLine(item.Text);
                    }
                }
            }
            using (StreamWriter writer = new StreamWriter(pointPath))
            {
                writer.WriteLine(lightLabel.Text);
                writer.WriteLine(darkLabel.Text);
            }
            disconnect.Enabled = false;
        }

        public void timer1_Tick(object sender, EventArgs e)
        {
            Thread.Sleep(1000);
            conn.Send("say", "Timer enabled");
            if (timer == interval)
            {
                Thread.Sleep(1000);
                conn.Send("say", "Timer deactivated. Key function");
                timer1.Enabled = false;
                timer = 0;
                Random random = new Random();
                int randomPathKey = random.Next(0, 7);
                if (randomPathKey == 0)
                {
                    conn.Send(worldKey + "r");
                }
                if (randomPathKey == 1)
                {
                    conn.Send(worldKey + "g");
                }
                if (randomPathKey == 2)
                {
                    conn.Send(worldKey + "b");
                }
                if (randomPathKey == 3)
                {
                    conn.Send(worldKey + "c");
                }
                if (randomPathKey == 4)
                {
                    conn.Send(worldKey + "m");
                }
                if (randomPathKey == 5)
                {
                    conn.Send(worldKey + "y");
                }
                if (randomPathKey == 6)
                {
                    Thread.Sleep(1000);
                    conn.Send("say", "None");
                }
            }
        }

        public void timer2_Tick(object sender, EventArgs e)
        {
            timer2.Enabled = false;
            antibug = false;
        }
    }
}

In any case, I have Team Viewer, so if you have time, you can have a look for yourself. I've been modifying this for a while now~

MOD EDIT: Removed passwords.

Offline

#15 2015-02-27 19:07:15, last edited by ewoke (2015-02-27 19:11:42)

ewoke
Member
Joined: 2015-02-20
Posts: 412

Re: Listbox&Listview problem with userdata

hey pssst you posted your password etc again

http://stackoverflow.com/questions/4731 … -and-4-etc
check this

i also leave this here
listView1.View = View.Details;


if you can read this....good for you

Offline

#16 2015-02-27 19:11:11

ZeldaXD
EE Homeboy
From: Cyprus
Joined: 2015-02-15
Posts: 1,539
Website

Re: Listbox&Listview problem with userdata

What a genius Psychocrysma, a mastermind of security.


gLjTZE1.png

Offline

#17 2015-02-27 19:15:46, last edited by Processor (2015-02-27 19:16:54)

Processor
Member
Joined: 2015-02-15
Posts: 2,246

Re: Listbox&Listview problem with userdata

10/10 Snipped password. Next time I'll use your acc to spam in every room and get your acc banned, lol

Jokes aside, change your account password please.


I have never thought of programming for reputation and honor. What I have in my heart must come out. That is the reason why I code.

Offline

#18 2015-02-27 21:47:17, last edited by Psychocrysma (2015-02-27 23:04:32)

Psychocrysma
Member
Joined: 2015-02-26
Posts: 46

Re: Listbox&Listview problem with userdata

ewoke wrote:

hey pssst you posted your password etc again

check this

i also leave this here
listView1.View = View.Details;

Know that~ BTW, I can't quote URLs

ZeldaXD wrote:

What a genius Psychocrysma, a mastermind of security.

Indeed. I'm probably known everywhere with that //forums.everybodyedits.com/img/smilies/wink

Processor wrote:

10/10 Snipped password. Next time I'll use your acc to spam in every room and get your acc banned, lol

Jokes aside, change your account password please.

I'll do that. Sorry for being such an idiot :x

I think I'll make a hidden label and take the password and email from there. I am quite forgetful. ADHD~

Offline

#19 2015-02-27 23:55:29

Psychocrysma
Member
Joined: 2015-02-26
Posts: 46

Re: Listbox&Listview problem with userdata

Well, you can close this thread or something. I have no idea why it did that, but I managed to get around it with a whole bunch of try and catch. There must be 5 of those and they are all like a labyrinth. Never going to read my own code again xD

Offline

#20 2015-02-28 00:41:53

Different55
Forum Admin
Joined: 2015-02-07
Posts: 16,574

Re: Listbox&Listview problem with userdata

Locked on request of owner.

In the future, if you want to make sure a topic gets locked, report it. Report something whenever it needs a forum mod's attention. You guys are a big part of our eyes and ears on the forums.


"Sometimes failing a leap of faith is better than inching forward"
- ShinsukeIto

Offline

Different551425080513477518

Board footer

Powered by FluxBB

[ Started around 1715010835.4548 - Generated in 0.176 seconds, 10 queries executed - Memory usage: 1.74 MiB (Peak: 2.02 MiB) ]