Discuss Scratch

GameNoob
Scratcher
19 posts

Amount of people on a project

I'm currently making an online multiplayer game (it's actually going really well) but I've hit a brick wall when it comes to finding the amount of people on a game. There are two teams (red and blue) and I need to know how many people there are on each team using cloud variables. Anyone know what to do?

bruh
Wetbikeboy2500
Scratcher
100+ posts

Amount of people on a project

how I would do it is when someone starts the game immediately save the cloud variables of the other players then test them a little later and if the variables are different that means there is someone there if there is not anyone there then they can take the account and you could make it so all the people who are playing their game could check to see what their game says is online if they are different then the game should recheck who is online and you could make the game recheck every so often. This may sound a little complicated but I hope you get it the reason it is so long is just so you do not have issues with people being there when they are not. like i said i hope it helps

Scratch Made In JavaScript: https://scratch.mit.edu/discuss/topic/171842
Scratch Browser: https://scratch.mit.edu/discuss/topic/285957/
SB2Downloader: https://scratch.mit.edu/discuss/topic/295425/
Multiple work stations: https://scratch.mit.edu/discuss/topic/122484/
New Blocks for Displaying Text: https://scratch.mit.edu/discuss/topic/171508
Sprite Folders: https://scratch.mit.edu/discuss/topic/171569/
Find code easier: https://scratch.mit.edu/discuss/topic/144748/
A Support Button or No support Button: https://scratch.mit.edu/discuss/topic/181154/
I want Scratch grow and become a better place for everyone to come and use. So Scratch needs to expand and have more options for everyone.Scratch needs to break the boundaries and not be trapped by what is familiar to Scratch community
danielperez
Scratcher
22 posts

Amount of people on a project

To answer your question, i have to know how did you make the multiplayer system, so i can help you

when i receive[potato v
repeat until<(potato)=(0
set[bite v] to (pick random(0.1)to(0.3))
eat(bite)[potatoes v]::motion
change[potato v]by((-1)*(bite))
end
say[I'm full!]
TheHockeyist
Scratcher
1000+ posts

Amount of people on a project

Finding the number of people on your game at a given instant would be extremely hard, if not impossible to do.


master_tolkien
Scratcher
100+ posts

Amount of people on a project

You have the usernames on an encoded cloud variable, separated by a 00. No letters, numbers, or characters should encode to 00.

For example, the “master” in my username might translate into: 00120119200518, which can be translated into:
player=00
m=12
a=01
and so on.

Then, each player's decoder has a function that counts the number of 00. This gives you the number of players.

The player list will have to be cleared and updated frequently so that players will not stay on it when they leave.

EDIT: Another option.
You have a cloud variable that is added to by a new player that clears itself frequently. When it does so, it asks each player to add to it again. This should be run in a custom block with the option “run without screen refresh” checked.

Last edited by master_tolkien (Dec. 28, 2014 20:15:47)


SCRRRRRRAAAAAAYYYYYTTTTCCHHHHH…

Swift, computer architecture, hippos.


Repeat: Programming Language in Scratch | Jump

gtoal
Scratcher
1000+ posts

Amount of people on a project

GameNoob wrote:

I'm currently making an online multiplayer game (it's actually going really well) but I've hit a brick wall when it comes to finding the amount of people on a game. There are two teams (red and blue) and I need to know how many people there are on each team using cloud variables. Anyone know what to do?

The underlying problem is knowing when a player has closed their browser window without explicitly logging out of the game. The solution is for active players to “ping” the game by updating a cloud variable reguarly, eg once every second. Then if you haven't heard from a player for more than a second, you assume they've left the game. (Or if you don't hear from anyone in more than a second, either everyone has left the game or you've lost your connection to the cloud server)

The details of pinging the server I leave up to you. Do post if you get something to work - I expect it will be tricky. You'll need to worry about interlocks and race conditions. It may not even be possible to do this in a provably reliable way.

G
Alberknyis
Scratcher
1000+ posts

Amount of people on a project

What gtoal said is very true.

I really think you should try something easier first.

stop [all v] ::stack
Wetbikeboy2500
Scratcher
100+ posts

Amount of people on a project

well I have been away but i finally came back and have made a demo of identification by testing minute hour and date and I did make it offline so there are no cloud variables the variables that would be cloud ones start with cloud this took me about an hour to do and was not too hard
go check it out

Scratch Made In JavaScript: https://scratch.mit.edu/discuss/topic/171842
Scratch Browser: https://scratch.mit.edu/discuss/topic/285957/
SB2Downloader: https://scratch.mit.edu/discuss/topic/295425/
Multiple work stations: https://scratch.mit.edu/discuss/topic/122484/
New Blocks for Displaying Text: https://scratch.mit.edu/discuss/topic/171508
Sprite Folders: https://scratch.mit.edu/discuss/topic/171569/
Find code easier: https://scratch.mit.edu/discuss/topic/144748/
A Support Button or No support Button: https://scratch.mit.edu/discuss/topic/181154/
I want Scratch grow and become a better place for everyone to come and use. So Scratch needs to expand and have more options for everyone.Scratch needs to break the boundaries and not be trapped by what is familiar to Scratch community

Powered by DjangoBB