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.
Hello,
So right now I have a bot that sends a user through a for loop of "/teleport"s that goes on for a bit when they use a command. But right now only one user can be in the loop at a time; if someone else uses the command while another is in the for loop, the bot waits until the other player is out of the for loop to push the next person in. What I want is for multiple people to be able to go through the loop at the same time. How would I do this?
Offline
Mutli-threading, learn how to do it now or suffer for the rest of your life.
Thank you eleizibeth ^
I stack my signatures rather than delete them so I don't lose them
Offline
Mutli-threading, learn how to do it now or suffer for the rest of your life.
care to elaborate please.
color = #1E1E1E
Offline
Koya wrote:Mutli-threading, learn how to do it now or suffer for the rest of your life.
care to elaborate please.
https://duckduckgo.com/?q=c%23+multithreading
Kinda why search engines exist
Thank you eleizibeth ^
I stack my signatures rather than delete them so I don't lose them
Offline
Mutli-threading, learn how to do it now or suffer for the rest of your life.
That, or he could create a loop that constantly wasted time checking to see if someone wanted to get sent in a loop, AND receive messages. Seems unlikely tho.
Offline
Koya wrote:Mutli-threading, learn how to do it now or suffer for the rest of your life.
care to elaborate please.
Okay so here's what you gotta do.
First you got your main thread that listens for commands and all that.
But then
when your bot hears the teleport command
it fires off a new thread and tells it to deal with teleporting the nub who said the teleport command
and then it goes back to listening.
That's the basic idea, anyway.
"Sometimes failing a leap of faith is better than inching forward"
- ShinsukeIto
Offline
If you're scared of threads, make a list of people to teleport, whenever somebody says the command, add the person in the list.
In the for-loop you loop through the list of people to teleport and you teleport them.
Offline
Offline
[ Started around 1732444452.8516 - Generated in 0.043 seconds, 12 queries executed - Memory usage: 1.49 MiB (Peak: 1.63 MiB) ]