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.
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
I know how to make bots W24. I just don't know how to make a joined list
Offline
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
http://capasha.com/eeinformation.php
Look under "add"
thanks zoey aaaaaaaaaaaand thanks latif for the avatar
Offline
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?
Offline
Google "How to add stuff to a listview"
can you help me now?
You don't think we were helping? Wow ok then
thanks zoey aaaaaaaaaaaand thanks latif for the avatar
Offline
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
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
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
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
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
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
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
@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
Offline
^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
http://wiki.everybodyedits.com/Guide:Bot_Programming
this is what I meant
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
Nothing wrong with disabling cross-threading
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
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.*
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
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
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 .
Offline
[ Started around 1732437756.5404 - Generated in 0.194 seconds, 12 queries executed - Memory usage: 1.74 MiB (Peak: 2 MiB) ]