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-10-21 16:55:51

AK712
Member
Joined: 2015-02-16
Posts: 94

[Question] For Loop with Multiple Users

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?


O4DmNuI.png

Offline

#2 2015-10-21 17:35:35

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

Re: [Question] For Loop with Multiple Users

Mutli-threading, learn how to do it now or suffer for the rest of your life.


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-10-21 20:11:01

shadowda
Member
From: somewhere probably.
Joined: 2015-02-19
Posts: 1,015

Re: [Question] For Loop with Multiple Users

Koya wrote:

Mutli-threading, learn how to do it now or suffer for the rest of your life.

care to elaborate please.


color = #1E1E1E       

latest?cb=20150604065609

Offline

#4 2015-10-21 20:55:45

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

Re: [Question] For Loop with Multiple Users

shadowda wrote:
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


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

#5 2015-10-21 22:11:49

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

Re: [Question] For Loop with Multiple Users

Koya wrote:

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

#6 2015-10-21 22:26:54

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

Re: [Question] For Loop with Multiple Users

shadowda wrote:
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

#7 2015-10-21 22:46:40

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

Re: [Question] For Loop with Multiple Users

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

#8 2015-10-22 00:14:39

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

Re: [Question] For Loop with Multiple Users

^See, I thought of that
but that still rqeuires the loop... and it'll still throw things out of place.
But a good idea.

@diff: eloquent

Offline

hummerz51445469279552051

Board footer

Powered by FluxBB

[ Started around 1713516944.8302 - Generated in 0.370 seconds, 10 queries executed - Memory usage: 1.48 MiB (Peak: 1.62 MiB) ]