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 2016-01-28 01:06:54

ZafingSpace
Member
Joined: 2016-01-26
Posts: 5

[Help me] How to make a proper user list

Well I want to make a list that has all username that in the world for my bot. Like the list to your right of your screen when you play everybody edits.

I'm a beginner at making bots so can you help me please and tell me what to use and where you put the code please(Be  Specific!).

Offline

#2 2016-01-28 01:14:40

W24
Member
From: USA
Joined: 2015-05-30
Posts: 591
Website

Re: [Help me] How to make a proper user list

I really don't know how to code, but from what I know, Microsoft Visual Studio is a program that you could use to code stuff.


yqSDpmp.png

Offline

#3 2016-01-28 01:29:34

ZafingSpace
Member
Joined: 2016-01-26
Posts: 5

Re: [Help me] How to make a proper user list

I know how to make bots W24. I just don't know how to make a joined list

Offline

#4 2016-01-28 02:19:07

hummerz5
Member
From: wait I'm not a secret mod huh
Joined: 2015-08-10
Posts: 5,853

Re: [Help me] How to make a proper user list

You want us to be specific but you don't want to be specific? What code do you have? Are you in a Console? have you started at all?
Do you have any knowledge in WinForms? Do you know what a control is?
Do you want help with the GUI aspect or simply the storing the information to memory?

Do you want me to ask more questions that are relevant, but should have already been answered in your first post?
Do you realize all these questions are really just to emphasize your lack of information?

Offline

#5 2016-01-28 03:13:47

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

Re: [Help me] How to make a proper user list


zsbu6Xm.png thanks zoey aaaaaaaaaaaand thanks latif for the avatar

Offline

#6 2016-01-28 03:56:07

ZafingSpace
Member
Joined: 2016-01-26
Posts: 5

Re: [Help me] How to make a proper user list

You want us to be specific but you don't want to be specific? 1. When I meant specific I mean like if you gave me a code where do I put it and what do I use to for convert the username name to? That specific
What code do you have? 2. I'm confused by this question but I think you mean what software I use and I use visual c# 2010 like in the Jabatheblob1 Tutorial
Are you in a Console? 3. Don't know what that means either sorry
have you started at all? 4. I've started on my bot, it's a information bot it knows if you touch a coin and join a world and where you place a block you get it
Do you have any knowledge in WinForms? 5. I probably don't know
Do you know what a control is? 6. I probably don't know too
Do you want help with the GUI aspect or simply the storing the information to memory? 7. Yes I need help with that

I'm sorry that I didn't have enough information in my first post

This is what I tired:

 switch (m.Type)
            {
                case "add":
                    users.Add(m.GetInt(0), new player { username = m.GetString(1), isPlaying = true });
                    userlist_ListView.Items.AddRange(new ListViewItem[] { users });
                    break;
            }

That what I did but it I know it's not gonna work so can you help me now? //forums.everybodyedits.com/img/smilies/neutral

Offline

#7 2016-01-28 13:39:14

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

Re: [Help me] How to make a proper user list

Google "How to add stuff to a listview"

ZafingSpace wrote:

can you help me now?

You don't think we were helping? Wow ok then


zsbu6Xm.png thanks zoey aaaaaaaaaaaand thanks latif for the avatar

Offline

#8 2016-01-28 14:19:55, last edited by capasha (2016-01-28 14:21:46)

capasha
Member
Joined: 2015-02-21
Posts: 4,066

Re: [Help me] How to make a proper user list

Adding listview in another thread, aka cross threading. You need to invoke the text to the listview.
Here is a little guide, to not disable cross threading. http://forums.everybodyedits.com/viewtopic.php?id=11626

And one more note. Read more about C# tutorials. I'm not going to learn you them.
You can't just think that you would do a bot in just some minute without knowing basics of C#.

Offline

#9 2016-01-28 18:39:33

Tomahawk
Forum Mod
From: UK
Joined: 2015-02-18
Posts: 2,847

Re: [Help me] How to make a proper user list

Nothing wrong with disabling cross-threading. Ignore the haters.

Actually helpful comments:

Your "users" variable seems to be a Dictionary<int, Player>. The first line of code in "add" in what you've tried will work fine.
The second line is the problem; is there a particular reason you're using a Listview over a Listbox? Listbox is great for displaying plain text in a list format, while Listview supports adding of objects like icons and buttons.

If you just want a list of player's usernames next to their IDs, you can replace that listview with a listbox, and for your second line of code do something like:

listBox1.Items.Add("[" + m.GetInt(0) + "] " + m.GetString(1));

~ You will also need to remove the player from the list when they leave the world. The easiest way to do this would be to clear the list, loop through "users" and display the items again every time someone leaves.


One bot to rule them all, one bot to find them. One bot to bring them all... and with this cliché blind them.

Offline

#10 2016-01-28 20:22:51, last edited by lrussell (2016-01-28 20:25:06)

lrussell
Member
From: Saturn's Titan
Joined: 2015-02-15
Posts: 843
Website

Re: [Help me] How to make a proper user list

Tomahawk wrote:

Nothing wrong with disabling cross-threading. Ignore the haters.

Actually helpful comments:

Your "users" variable seems to be a Dictionary<int, Player>. The first line of code in "add" in what you've tried will work fine.
The second line is the problem; is there a particular reason you're using a Listview over a Listbox? Listbox is great for displaying plain text in a list format, while Listview supports adding of objects like icons and buttons.

If you just want a list of player's usernames next to their IDs, you can replace that listview with a listbox, and for your second line of code do something like:

listBox1.Items.Add("[" + m.GetInt(0) + "] " + m.GetString(1));

~ You will also need to remove the player from the list when they leave the world. The easiest way to do this would be to clear the list, loop through "users" and display the items again every time someone leaves.

It's not a matter of "ignore the haters". While in this case it probably wouldn't matter, it is possible to run into race conditions resulting in unwanted values ending up on your form. It's good practice to invoke, because it acts as a buffer and keeps everything on one thread.

Here's a good example where this can be an issue: http://www.coderail.com/thread-3.html

Offline

#11 2016-01-28 21:45:40

Tomahawk
Forum Mod
From: UK
Joined: 2015-02-18
Posts: 2,847

Re: [Help me] How to make a proper user list

Leave it be.

It doesn't make the tiniest bit of visible difference, except that invoking is more work and makes you feel good about yourself for using more complex code. That example is a pretty weak one.


One bot to rule them all, one bot to find them. One bot to bring them all... and with this cliché blind them.

Offline

#12 2016-01-28 23:04:53, last edited by lrussell (2016-01-28 23:08:30)

lrussell
Member
From: Saturn's Titan
Joined: 2015-02-15
Posts: 843
Website

Re: [Help me] How to make a proper user list

Tomahawk wrote:

Leave it be.

It doesn't make the tiniest bit of visible difference, except that invoking is more work and makes you feel good about yourself for using more complex code. That example is a pretty weak one.

That's why I said it probably doesn't matter in this case. There's only one other thread modifying the control, and the main thread isn't likely to touch it because it needs player data. But there isn't any sense in scaring them away from invoking. It has nothing to do with "[feeling] good about yourself for using more complex code". It prevents potential problems in the future when working on, yes, more complex projects.

How is that example weak, anyway? It validly demonstrates a race condition that can result in seemingly random behavior. Sometimes the button is visible, and sometimes it isn't using the same code!

Offline

#13 2016-01-28 23:19:22

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

Re: [Help me] How to make a proper user list

Tomahawk wrote:

Nothing wrong with disabling cross-threading. Ignore the haters.

OH MY GATES DID YOU JUST SAY THAT ITS FINE TO DO THAT?

I can handle it if people are too lazy or inexperienced and use these kind of hacks to speed up their time, but telling others that this is just fine is crossing a line. It is totally not fine (Buzz's topic covers up why pretty nicely so look at that) and it is very unprofessional of you to mislead people like this.


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

#14 2016-01-28 23:19:25, last edited by hummerz5 (2016-01-28 23:20:36)

hummerz5
Member
From: wait I'm not a secret mod huh
Joined: 2015-08-10
Posts: 5,853

Re: [Help me] How to make a proper user list

http://wiki.everybodyedits.com/Guide:Bot_Programming
^check this out for starters. You're expressing a lack of knowledge in the area which will slow your progress dramatically. Either your determination will make you stick with it for a terribly long time, or you'll get bored and give up.

If you want to see this through, you need more knowledge. Try the guide, then consider jabatheblob's tutorials. Did you finish them all? Did you understand every piece?

(aside: I haven't reviewed jaba's tutorials. Are they a "monkey see monkey do" or a "here's why we do this" ?)

(aside 2: we've already discussed the threading issue. Let's agree that the issue hasn't been decided. It's above the scope of this discussion by any means)

edit: no I'm not condoning the method, but if someone says yes and someone says no, it's easier to say "we don't know" than to try and argue more. And yes, you can argue "but that doesn't make it right" but at that point you're wasting your time.

Offline

#15 2016-01-29 01:28:08

den3107
Member
From: Netherlands
Joined: 2015-04-24
Posts: 1,025

Re: [Help me] How to make a proper user list

@hummerz5:
I wouldn't really say this is a problem where he didn't watch the tutorials, but basic C# and programming skill.
I'm pretty certain he will now simply append the entire list + the new player to the list every time somebody joins, instead of showing the new actual list of players (tip: clear the list, THEN add the entire users list).
I personally also doubt he will get the result he wishes, since I doubt he overrided the ToString() function with return the player's name. (tip: do what I just said).
The delegate stuff is something anybody would trip over when just starting programming a bot like this.
I'm thinking about making a tutorial about general skills that might be useful, the problem is that I don't know myself what the correct way is to do threading (even though I think my current method seems fine), bus aside from threading, quite some things can be learned, of course in the theme of EE bots.

Offline

#16 2016-01-29 01:29:56

hummerz5
Member
From: wait I'm not a secret mod huh
Joined: 2015-08-10
Posts: 5,853

Re: [Help me] How to make a proper user list

^such is why I made a wiki way so if I was wrong, someone would right it.

And if someone else had ideas, they could contribute

but hey you do you

Offline

#17 2016-01-29 02:02:28

den3107
Member
From: Netherlands
Joined: 2015-04-24
Posts: 1,025

Re: [Help me] How to make a proper user list

hummerz5 wrote:

^such is why I made a wiki way so if I was wrong, someone would right it.

And if someone else had ideas, they could contribute

but hey you do you

Never saw that one...
Link?

Offline

#18 2016-01-29 02:02:59

hummerz5
Member
From: wait I'm not a secret mod huh
Joined: 2015-08-10
Posts: 5,853

Re: [Help me] How to make a proper user list

Offline

#19 2016-01-29 15:21:44

den3107
Member
From: Netherlands
Joined: 2015-04-24
Posts: 1,025

Re: [Help me] How to make a proper user list

hummerz5 wrote:

Would you mind if we'd bring this to PM? I have a couple things I'd like to talk about, and obviously we're trailing a bit off the scope of this topic.

Offline

#20 2016-01-29 19:24:52, last edited by Tomahawk (2016-01-29 19:26:29)

Tomahawk
Forum Mod
From: UK
Joined: 2015-02-18
Posts: 2,847

Re: [Help me] How to make a proper user list

Tomahawk wrote:

Nothing wrong with disabling cross-threading

Processor wrote:

It is totally not fine

What if I put it this way:

In the majority of cases, and certainly for the vast majority of bots, disabling that bool and cross-threading will produce the same result as invoking, without burning the house down around you. Regardless of how bad an example it might be for more complex projects, this is a bot thread in the bot forum section and I am allowed to advise a newbie coder to use simpler, less safe code rather than to take advice from those who see Stack Overflow as being the one and only true path.

Either way, this thread is about displaying players in a list and not about the sacrilege that is illegal cross-thread calling, so the last 10 or so posts are irrelevant and this chain shouldn't have been started.


One bot to rule them all, one bot to find them. One bot to bring them all... and with this cliché blind them.

Offline

#21 2016-01-29 19:45:12

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

Re: [Help me] How to make a proper user list

There is a difference between simple and plain wrong code. Don't teach people to use stupid hacks like these. The newbies don't have a good grasp of the concepts behind difficult programming concepts such as threading, they wont be able to understand the implications of enabling such a dangerous feature. Teaching them the wrong stuff will be very bad for them in the long run.

I've been programming for so long and I still believe in the fact that every problem has an elegant simple solution to it. No need to fall back to using stupid hacks.*

Tomahawk wrote:

Either way, this thread is about displaying players in a list and not about the sacrilege that is illegal cross-thread calling, so the last 10 or so posts are irrelevant.

If the OP doesn't tell us if their issue still persists, I will close the topic soon.


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

#22 2016-01-29 21:20:49

Tomahawk
Forum Mod
From: UK
Joined: 2015-02-18
Posts: 2,847

Re: [Help me] How to make a proper user list

Gah, stop exaggerating. Nobody gives a damn.


One bot to rule them all, one bot to find them. One bot to bring them all... and with this cliché blind them.

Offline

#23 2016-02-09 23:57:40

ZafingSpace
Member
Joined: 2016-01-26
Posts: 5

Re: [Help me] How to make a proper user list

Tomahawk wrote:

listBox1.Items.Add("[" + m.GetInt(0) + "] " + m.GetString(1));

Thanks for the help for adding the usernames. I did the removing on my own //forums.everybodyedits.com/img/smilies/smile .

Offline

ZafingSpace1455058660581706

Board footer

Powered by FluxBB

[ Started around 1732759547.2191 - Generated in 0.091 seconds, 13 queries executed - Memory usage: 1.74 MiB (Peak: 2 MiB) ]