Discuss Scratch

_THEBOSS_7
Scratcher
500+ posts

how do you make a players online counter?

i assume it is a simple script? just counting how many players are online w/cloud variables?

I AM THEBOSS

PLAY AN ACTUALLY UNIQUE .IO GAME, Swords.io! —–> https://scratch.mit.edu/projects/435457725/


do you need your game beta-tested? try the Beta-Bugs shop!
https://scratch.mit.edu/discuss/topic/475356/
DerpyHead0
Scratcher
1000+ posts

how do you make a players online counter?

TLDR: as just a player counter for your project, it's impossble. if this is for cloud multiplayer, keep reading

it's easy to detect when a player connects, but checking for a player disconnect is a lot more complicated, because it means the code stops running entirely. stop button detection won't work here either, since they could just close the page.

what you need is another player to keep track of the disconnected player, and for online players to constantly update a cloud variable. however, this maxes out at the amount of cloud variables you have (10 if i remember correctly) because multiple players sharing the same variable will cause issues as players with lag overwrite each other.

all this is fine for cloud multiplayer with a player limit, but just trying to use it to count any player on the project isn't possible.

Last edited by DerpyHead0 (Nov. 30, 2020 17:21:03)


when I start as a clone
delete this clone
BlockGardens
Scratcher
13 posts

how do you make a players online counter?

This is actually possible, you just have a limit. Let's say the limit is 256, to simplify things. There must be one variable, called “tick”. If all 256 slots are full, it should look something like this.
0001011101101010101… and so on.
What we need is to be able to keep track of all of the digits at once. Your tick should be changing from 0 to 1 every 0.1 seconds, and there can be 256 clones to keep track of their individual tick. (I'd tell you how to use CloneID, but i'm assuming you're not a noob.)
They should wait 3 times, and check if all times are the same. They wait 0.1 seconds each time (obviously), so it should take 0.3 seconds to delete a player if they're inactive.
For example, if their recording is 000 or 111, that player is inactive and can be kicked out. But if it's 001 or 110 or 010 or such, that player can be ignored for now.
This is just a quick summary of how it works. Actually doing it would be considerably harder.
To measure the number of players, that's easy, just do length(allTicks).

Hi! I'm BlockGardens!
DerpyHead0
Scratcher
1000+ posts

how do you make a players online counter?

BlockGardens wrote:

This is actually possible, you just have a limit. Let's say the limit is 256, to simplify things. There must be one variable, called “tick”. If all 256 slots are full, it should look something like this.
0001011101101010101… and so on.
What we need is to be able to keep track of all of the digits at once. Your tick should be changing from 0 to 1 every 0.1 seconds, and there can be 256 clones to keep track of their individual tick. (I'd tell you how to use CloneID, but i'm assuming you're not a noob.)
They should wait 3 times, and check if all times are the same. They wait 0.1 seconds each time (obviously), so it should take 0.3 seconds to delete a player if they're inactive.
For example, if their recording is 000 or 111, that player is inactive and can be kicked out. But if it's 001 or 110 or 010 or such, that player can be ignored for now.
This is just a quick summary of how it works. Actually doing it would be considerably harder.
To measure the number of players, that's easy, just do length(allTicks).
that acutally doesn't work, because online players set the ENTIRE variable. so if someone that has bad internet joins, they'll keep overwriting the cloud variable with old data (which means overwriting everyone's ticks) and stop the ticks from working properly.

also, 256 clones just sitting in the background isn't a good idea, that would cause tons of unneccecary lag and leaves less room in the project for other clones.

when I start as a clone
delete this clone
BlockGardens
Scratcher
13 posts

how do you make a players online counter?

DerpyHead0 wrote:

BlockGardens wrote:

This is actually possible, you just have a limit. Let's say the limit is 256, to simplify things. There must be one variable, called “tick”. If all 256 slots are full, it should look something like this.
0001011101101010101… and so on.
What we need is to be able to keep track of all of the digits at once. Your tick should be changing from 0 to 1 every 0.1 seconds, and there can be 256 clones to keep track of their individual tick. (I'd tell you how to use CloneID, but i'm assuming you're not a noob.)
They should wait 3 times, and check if all times are the same. They wait 0.1 seconds each time (obviously), so it should take 0.3 seconds to delete a player if they're inactive.
For example, if their recording is 000 or 111, that player is inactive and can be kicked out. But if it's 001 or 110 or 010 or such, that player can be ignored for now.
This is just a quick summary of how it works. Actually doing it would be considerably harder.
To measure the number of players, that's easy, just do length(allTicks).
that acutally doesn't work, because online players set the ENTIRE variable. so if someone that has bad internet joins, they'll keep overwriting the cloud variable with old data (which means overwriting everyone's ticks) and stop the ticks from working properly.

also, 256 clones just sitting in the background isn't a good idea, that would cause tons of unneccecary lag and leaves less room in the project for other clones.
Hm, I never thought about that. Maybe we can use Translate and forbid anyone with bad internet from joining? And make every clone handle 4 ticks rather than 1?

Hi! I'm BlockGardens!
_THEBOSS_7
Scratcher
500+ posts

how do you make a players online counter?

guess its not as simple as i thought…. clones are no problem for me, lag sure, but i am not using clones.

Last edited by _THEBOSS_7 (Nov. 30, 2020 17:40:28)


I AM THEBOSS

PLAY AN ACTUALLY UNIQUE .IO GAME, Swords.io! —–> https://scratch.mit.edu/projects/435457725/


do you need your game beta-tested? try the Beta-Bugs shop!
https://scratch.mit.edu/discuss/topic/475356/
BlockGardens
Scratcher
13 posts

how do you make a players online counter?

Yeah.

Hi! I'm BlockGardens!
DerpyHead0
Scratcher
1000+ posts

how do you make a players online counter?

BlockGardens wrote:

Maybe we can use Translate and forbid anyone with bad internet from joining?
it would be almost impossible to check if someone is messing up other players ticks, and if this means preventing people from playing the game properly, it's a really bad idea.

_THEBOSS_7 wrote:

guess its not as simple as i thought…. clones are no problem for me, lag sure, but i am not using clones.
lag can prevent a lot of people with worse computers from playing the game, and again, preventing people from playing the game properly is a terrible idea.

what do you even need this online counter for? is it acutally important for the game, is the game multiplayer, or is it just something cool? because if it's not needed i don't think it's worth adding, if it's just some counter to try and show how popular the game is, there's lots of other things you can do, like a top score list, a counter for players that have beaten the game, etc.

when I start as a clone
delete this clone
_THEBOSS_7
Scratcher
500+ posts

how do you make a players online counter?

it's not a game, it's a reverse whitelisted chat. link; ( it broken rn ) https://scratch.mit.edu/projects/455826566/

I AM THEBOSS

PLAY AN ACTUALLY UNIQUE .IO GAME, Swords.io! —–> https://scratch.mit.edu/projects/435457725/


do you need your game beta-tested? try the Beta-Bugs shop!
https://scratch.mit.edu/discuss/topic/475356/
DerpyHead0
Scratcher
1000+ posts

how do you make a players online counter?

2 things:
1) this project is just a regular whitelist, you have whitelist and blacklist mixed up
2) online chats aren't allowed on scratch, even with the whitelist

when I start as a clone
delete this clone
_THEBOSS_7
Scratcher
500+ posts

how do you make a players online counter?

whitelists only stop certain words, this ONLY allows words in the list, so it is not technically an open chat.
( come to think of it you are prob. right, but this is not open chat, it's technically the same thing as looking at a ton of buttons and choosing what word to say, except u type )

Last edited by _THEBOSS_7 (Nov. 30, 2020 18:29:39)


I AM THEBOSS

PLAY AN ACTUALLY UNIQUE .IO GAME, Swords.io! —–> https://scratch.mit.edu/projects/435457725/


do you need your game beta-tested? try the Beta-Bugs shop!
https://scratch.mit.edu/discuss/topic/475356/
DerpyHead0
Scratcher
1000+ posts

how do you make a players online counter?

_THEBOSS_7 wrote:

whitelists only stop certain words, this ONLY allows words in the list, so it is not technically an open chat.
no, blacklists only stop certain words, and it's still an online chat. people can still put words together to insult people, give contact info, etc. it doesn't matter how you limit the words, until it gets to the point where it's not even a chat anymore.

the only thing i think is allowed is only being able to select from a list of possible messages, which then you can't really have any kind of conversation.

when I start as a clone
delete this clone
diggy5555
Scratcher
2 posts

how do you make a players online counter?

um my game isn't working and i don't have much experience with online games game issue
_THEBOSS_7
Scratcher
500+ posts

how do you make a players online counter?

diggy5555 wrote:

um my game isn't working and i don't have much experience with online games game issue
1) make your own topic next time
2) can't help you, sorry.

I AM THEBOSS

PLAY AN ACTUALLY UNIQUE .IO GAME, Swords.io! —–> https://scratch.mit.edu/projects/435457725/


do you need your game beta-tested? try the Beta-Bugs shop!
https://scratch.mit.edu/discuss/topic/475356/
BlockGardens
Scratcher
13 posts

how do you make a players online counter?

DerpyHead0 wrote:

BlockGardens wrote:

Maybe we can use Translate and forbid anyone with bad internet from joining?
it would be almost impossible to check if someone is messing up other players ticks, and if this means preventing people from playing the game properly, it's a really bad idea.

_THEBOSS_7 wrote:

guess its not as simple as i thought…. clones are no problem for me, lag sure, but i am not using clones.
lag can prevent a lot of people with worse computers from playing the game, and again, preventing people from playing the game properly is a terrible idea.

what do you even need this online counter for? is it acutally important for the game, is the game multiplayer, or is it just something cool? because if it's not needed i don't think it's worth adding, if it's just some counter to try and show how popular the game is, there's lots of other things you can do, like a top score list, a counter for players that have beaten the game, etc.
Wait, what if we use a “temp” variable?

Hi! I'm BlockGardens!
_THEBOSS_7
Scratcher
500+ posts

how do you make a players online counter?

wdym?

I AM THEBOSS

PLAY AN ACTUALLY UNIQUE .IO GAME, Swords.io! —–> https://scratch.mit.edu/projects/435457725/


do you need your game beta-tested? try the Beta-Bugs shop!
https://scratch.mit.edu/discuss/topic/475356/
coooolboy55
Scratcher
56 posts

how do you make a players online counter?

its possible

variables

a cloud variable called max
a local variable called tcgf (times clicked green flag)

code

when green flag clicked

change max by 1

change tcgf by 1

if tcgf > 1 then

change max by -1

forever

reset timer

2nd code

when timer > 0

change max by -1

set tgcf to 0


IMAhomosapien
Scratcher
100+ posts

how do you make a players online counter?

when green flag clicked
change(☁ players)by (1)
coooolboy55
Scratcher
56 posts

how do you make a players online counter?

oops the tcgf variable is not local its global
coooolboy55
Scratcher
56 posts

how do you make a players online counter?

Powered by DjangoBB