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-07-04 03:25:02

cercul1
Member
From: USA
Joined: 2015-02-18
Posts: 91

Multiple timers

I need a way to create multiple timers for each player that joins the world.


Om_1869ea_249353.jpg

Offline

#2 2015-07-04 04:32:43

SirJosh3917
Formerly ninjasupeatsninja
From: USA
Joined: 2015-04-05
Posts: 2,095

Re: Multiple timers

Explain please? All I'm thinking is using background workers right now.

Offline

#3 2015-07-04 05:42:03

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

Re: Multiple timers

Player joins -> Create timer

So that he can use multiple timers because the code he has now doesn't work like he wants to.


zsbu6Xm.png thanks zoey aaaaaaaaaaaand thanks latif for the avatar

Offline

#4 2015-07-04 05:44:58

cercul1
Member
From: USA
Joined: 2015-02-18
Posts: 91

Re: Multiple timers

I think this is what you mean by explain:

     I'm making an RP bot that will be as close to life as I can get, and one of the aspects is hunger, thirst, and energy.  So I need it so that every time a play joins the world, it will create the 3 timers for every player.  If you need more info, just ask for what you need to know.


Om_1869ea_249353.jpg

Offline

#5 2015-07-04 05:48:25

Krosis
Formerly Arkonagames
Joined: 2015-06-17
Posts: 2,279
Website

Re: Multiple timers

cercul1 wrote:

I think this is what you mean by explain:

     I'm making an RP bot that will be as close to life as I can get, and one of the aspects is hunger, thirst, and energy.  So I need it so that every time a play joins the world, it will create the 3 timers for every player.  If you need more info, just ask for what you need to know.

I think you can do it with bot, but if all the timers have the same time you can use curse (well if you use curse you can't regenerate your hungry by example)


Krosis.gif

Offline

#6 2015-07-04 06:58:09, last edited by den3107 (2015-07-04 06:59:41)

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

Re: Multiple timers

Use a list of Tuples, where the tuple consists out of an int (player id), and 3 timers.

Everytime a player joins you add a tuple to the list and start the timers whenever.

I suggest though not to start the timer the moment they join, but make a small lobby, where a purple switch (or something) will notify your bot the player is joining the actual game.

Hope this helps.

Offline

#7 2015-07-04 07:54:39

BuzzerBee
Forum Admin
From: Texas, U.S.A.
Joined: 2015-02-15
Posts: 4,575

Re: Multiple timers

den3107 wrote:

Use a list of Tuples, where the tuple consists out of an int (player id), and 3 timers.

Everytime a player joins you add a tuple to the list and start the timers whenever.

I suggest though not to start the timer the moment they join, but make a small lobby, where a purple switch (or something) will notify your bot the player is joining the actual game.

Hope this helps.

I wouldn't use a Tuple, I would make a Player class with a timer as a variable.


TdQRyz3.png
https://wiki.everybodyedits.com/images/5/5d/135_bee

Offline

#8 2015-07-04 18:30:31

DarkDragon4900
Member
Joined: 2015-03-17
Posts: 251

Re: Multiple timers

BuzzerBee wrote:
den3107 wrote:

Use a list of Tuples, where the tuple consists out of an int (player id), and 3 timers.

Everytime a player joins you add a tuple to the list and start the timers whenever.

I suggest though not to start the timer the moment they join, but make a small lobby, where a purple switch (or something) will notify your bot the player is joining the actual game.

Hope this helps.

I wouldn't use a Tuple, I would make a Player class with a timer as a variable.

^ yep.
And add them to a dictionary/list or something.

Offline

#9 2015-07-04 20:53:08

Zumza
Member
From: root
Joined: 2015-02-17
Posts: 4,656

Re: Multiple timers

Make a list of  Player classes
Then make a thread that choose the lowest value of time, from that array and waits until that time passes. Then update the values. Where is 0 you do ...what you need...


Everybody edits, but some edit more than others

Offline

#10 2015-07-05 02:30:02, last edited by cercul1 (2015-07-05 02:30:25)

cercul1
Member
From: USA
Joined: 2015-02-18
Posts: 91

Re: Multiple timers

den3107 wrote:

I suggest though not to start the timer the moment they join, but make a small lobby, where a purple switch (or something) will notify your bot the player is joining the actual game.

I like this idea, but i think it's just best to start it as soon as they join and it'd be more realistic because, you can't just decide when you wanna live.


Om_1869ea_249353.jpg

Offline

#11 2015-07-05 02:51:59

SirJosh3917
Formerly ninjasupeatsninja
From: USA
Joined: 2015-04-05
Posts: 2,095

Re: Multiple timers

cercul1 wrote:
den3107 wrote:

I suggest though not to start the timer the moment they join, but make a small lobby, where a purple switch (or something) will notify your bot the player is joining the actual game.

I like this idea, but i think it's just best to start it as soon as they join and it'd be more realistic because, you can't just decide when you wanna live.

lol xD

Offline

#12 2015-07-05 15:35:57

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

Re: Multiple timers

cercul1 wrote:
den3107 wrote:

I suggest though not to start the timer the moment they join, but make a small lobby, where a purple switch (or something) will notify your bot the player is joining the actual game.

I like this idea, but i think it's just best to start it as soon as they join and it'd be more realistic because, you can't just decide when you wanna live.

Can't you do that in exactly every RPG? Just close the game (leave room) or pause it (gotto starting lobby) and you're pausing your life, simple as that.

The reason why it's a bad choice to let the timers start instantly is because you're giving the players no time to check out the room first, acclimate to their surrounding, etc. etc.

Offline

#13 2015-07-05 18:50:35

eeisold
Member
Joined: 2015-06-14
Posts: 202

Re: Multiple timers

I could see where the timers need be paused until the user is ready. However, programmer's decision.

However, I'm not an RPG player. can you explain why you need a timer for each individual player as opposed to simply having three timers? Better yet, find the greatest common factor of each timer's interval and then just run the event based on when the timer has clicked (interval / GCF) times.

Or am I simply over-optimizing resource usage when there's only ~40 max players at one time? (120 timers)

Take den's programming advice if you don't already have other data stored for each player. Since you're running an RPG, you should most likely not take den's advice.

Buzzerbee suggests creating a class to represent your average player. This seems most useful as you could then easily add per-user properties without having to write the add/left message hooks for each property.

So, buzzerbee says a variable for each instance (non-static) whereas my suggestion would be a max of three (or even one) timer instance (static) for all players.
(in that case, you wouldn't access the local, you'd loop through all the players.)

Offline

#14 2015-07-06 12:41:44

DarkDragon4900
Member
Joined: 2015-03-17
Posts: 251

Re: Multiple timers

eeisold wrote:

*snip*

So, buzzerbee says a variable for each instance (non-static) whereas my suggestion would be a max of three (or even one) timer instance (static) for all players.
(in that case, you wouldn't access the local, you'd loop through all the players.)

Wait, so you mean that he should only use 3 timers that represent all of the players' hunger, thirst and sleep (or whatever his survival factors are) needs?

Offline

#16 2015-07-06 13:28:06

DarkDragon4900
Member
Joined: 2015-03-17
Posts: 251

Re: Multiple timers

I just don't get how you want all of the players to share the same survival meters.

Offline

#18 2015-07-06 21:19:11

DarkDragon4900
Member
Joined: 2015-03-17
Posts: 251

Re: Multiple timers

Because you wouldn't want all of the users in a room to die because of one of the players' failure in survival.

Offline

#19 2015-07-06 22:52:00

Vasum01
Member
Joined: 2015-06-28
Posts: 102

Re: Multiple timers

eeisold wrote:

And I don't get why you wouldn't

Each player needs their own health/hunger for couldn't-be-more-obvious reasons.

Offline

#20 2015-07-07 20:50:15

cercul1
Member
From: USA
Joined: 2015-02-18
Posts: 91

Re: Multiple timers

den3107 wrote:
cercul1 wrote:
den3107 wrote:

I suggest though not to start the timer the moment they join, but make a small lobby, where a purple switch (or something) will notify your bot the player is joining the actual game.

I like this idea, but i think it's just best to start it as soon as they join and it'd be more realistic because, you can't just decide when you wanna live.

Can't you do that in exactly every RPG? Just close the game (leave room) or pause it (gotto starting lobby) and you're pausing your life, simple as that.

The reason why it's a bad choice to let the timers start instantly is because you're giving the players no time to check out the room first, acclimate to their surrounding, etc. etc.


first of all, this isn't an rpg it's an rp
second of all, it's supposed to be like life, not a game
third of all i still want to start it right away, k thx


Om_1869ea_249353.jpg

Offline

#21 2015-07-07 22:21:18

Jabatheblob1
Member
Joined: 2015-03-01
Posts: 856

Re: Multiple timers

you don't need multiple timers. You need one timer that will change everyones stats when it is called.


If you would like me to make a bot for you, go here.

Offline

#22 2015-07-08 22:59:22

eeisold
Member
Joined: 2015-06-14
Posts: 202

Re: Multiple timers

Vasum01 wrote:
eeisold wrote:

And I don't get why you wouldn't

Each player needs their own health/hunger for couldn't-be-more-obvious reasons.

Please do enlighten me.
The only instance I can see that being an issue is if you can't have each user decrement at the same time.
in other words, the only time you can't have three timers is if the hunger takes 10 seconds and you join five seconds in between.

I'm going to change my suggestion. Don't use any timers at all. Whenever you need to determine the hunger depreciation (or whatever changes over time), do the calculation then. That's what EE does for energy. It doesn't record how much energy you have, only the date and time that it will be full.
I know, math isn't fun. But if you're going down this road of computer science, you'd better jump to it.

Offline

#23 2015-07-09 02:39:25

Jabatheblob1
Member
Joined: 2015-03-01
Posts: 856

Re: Multiple timers

Guys.... Just make one timer.

TIMER HERE
{
foreach (player p in DICTIONARY)
{
p.hunger-=10;
}
}

That is what eeisold is saying. Which is probably the easiest way. Just make sure to enable to timer.


If you would like me to make a bot for you, go here.

Offline

#24 2015-07-09 18:17:30

eeisold
Member
Joined: 2015-06-14
Posts: 202

Offline

#25 2015-07-09 19:51:52

Jabatheblob1
Member
Joined: 2015-03-01
Posts: 856

Re: Multiple timers

i made a tutorial for creating classes. I can create one for timers too if he needs that


If you would like me to make a bot for you, go here.

Offline

Jabatheblob11436467912520107

Board footer

Powered by FluxBB

[ Started around 1734850419.0157 - Generated in 0.104 seconds, 12 queries executed - Memory usage: 1.76 MiB (Peak: 2.01 MiB) ]