Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Cloud Data Help
- maximcaux
-
37 posts
Cloud Data Help
Simplest way to do it for 2 players:
Make seven variables. Make all of them except for player ID CLOUD variables by pressing the ‘cloud data: stored on server’ checkmark.
set cloud check to one. When someone tries to run the program and he can read the cloud variable, that means he is connected to the cloud. He will not be if he is on the offline editor, or a new scratcher. In the first instance we check if it is set to one, then we tell him he is connected. If it is zero, the default variable value, the game will tell him that he is not connected or is a new scratcher.
In player1:
Do nearly the same script in your second player. Here is what it should look like:
When the broadcasts are broadcasted, a sprite should tell the player the message of the broadcast.
For the rest of this to see if a player has left or not, go to the scratch wiki: https://wiki.scratch.mit.edu/wiki/How_to_Make_a_Multiplayer_Game
Here nearly everything is done the same way. Use the player 1 and 2 checks and the local ones to check if a player has left or not. You could also just do the whole tutorial from there than from here if you want.
Make seven variables. Make all of them except for player ID CLOUD variables by pressing the ‘cloud data: stored on server’ checkmark.
(cloud check)
(xp1)
(yp1)
(xp2)
(yp2)
(amountOfPlayers)
(player ID)
set cloud check to one. When someone tries to run the program and he can read the cloud variable, that means he is connected to the cloud. He will not be if he is on the offline editor, or a new scratcher. In the first instance we check if it is set to one, then we tell him he is connected. If it is zero, the default variable value, the game will tell him that he is not connected or is a new scratcher.
In player1:
when green flag clicked
forever
if <[cloud check] = [1 ]> then
if <[player ID] = [1 ]> then
go to x: (xp1) y: (yp1)
end
end
end
when green flag clicked
if <[cloud check] = [ 1]> then
if <[amountOfPlayers] = [ 0]> then
set [player ID v] to [player 1 ]
change [amountOfPlayers v] by (1)
broadcast [connected v]
forever
if <key [left arrow v] pressed?> then
change [xp1 v] by (5)
end
if <key [right arrow v] pressed?> then
change [xp1 v] by (-5)
end
if <key [up arrow v] pressed?> then
change [yp1 v] by (5)
end
if <key [down arrow v] pressed?> then
change [yp1 v] by (-5)
end
end
end
end
when green flag clicked
if <[cloud check] = [ 1]> then
if <[amountOfPlayers] = [ 2]> then
broadcast [sorry, the server is full! v]
end
end
when green flag clicked
if <[cloud check] = [0]> then
broadcast [sorry, not connected! v]
end
Do nearly the same script in your second player. Here is what it should look like:
when green flag clicked
forever
if <[cloud check] = [1 ]> then
if <[player ID] = [2 ]> then
go to x: (xp2) y: (yp2)
end
end
end
when green flag clicked
if <[cloud check] = [ 1]> then
if <[amountOfPlayers] = [ 1]> then
set [player ID v] to [player 2 ]
change [amountOfPlayers v] by (1)
broadcast [connected v]
forever
if <key [left arrow v] pressed?> then
change [xp2 v] by (5)
end
if <key [right arrow v] pressed?> then
change [xp2 v] by (-5)
end
if <key [up arrow v] pressed?> then
change [yp2 v] by (5)
end
if <key [down arrow v] pressed?> then
change [yp2 v] by (-5)
end
end
end
end
When the broadcasts are broadcasted, a sprite should tell the player the message of the broadcast.
For the rest of this to see if a player has left or not, go to the scratch wiki: https://wiki.scratch.mit.edu/wiki/How_to_Make_a_Multiplayer_Game
Here nearly everything is done the same way. Use the player 1 and 2 checks and the local ones to check if a player has left or not. You could also just do the whole tutorial from there than from here if you want.
Last edited by maximcaux (May 5, 2016 12:48:58)
- Thinktdm
-
79 posts
Cloud Data Help
you have to be a scratcherWith cloud variables.how do you do cloud variables?
Last edited by Thinktdm (May 5, 2016 22:31:15)
- Thinktdm
-
79 posts
Cloud Data Help
With cloud variables.Well, I already know,but i want to see if there is another way

- maximcaux
-
37 posts
Cloud Data Help
Dont advertise.
And BTW, i know no other way to create multiplayer games than using cloud variables.
And BTW, i know no other way to create multiplayer games than using cloud variables.
- MellerReal
-
88 posts
Cloud Data Help
It's not that easy you think it is to create a multiplayer, First you need to get known to cloud vars, Try creating highscore lists, username encrypting etc, Then look at @maximcaux's post, That's the easiest way to create a multiplayer game.
- deck26
-
1000+ posts
Cloud Data Help
https://scratch.mit.edu/projects/77775784/
may help - you don't need 7 cloud variables for 2 players but you do have to use cloud variables if by multiplayer you mean people on different computers.
Last edited by deck26 (June 10, 2016 13:41:09)
- Bryan007
-
100+ posts
Cloud Data Help
Check out @griffpatch .
He makes the best games on multiplayer.
He makes the best games on multiplayer.
- Thinktdm
-
79 posts
Cloud Data Help
Check out @griffpatch .I know this thread is 2 months old
He makes the best games on multiplayer.
- SparkDrawsFurryStuff
-
56 posts
Cloud Data Help
yesyou have to be a scratcherWith cloud variables.how do you do cloud variables?
- SpinningCube
-
100+ posts
Cloud Data Help
griffpatch's youtube channel has a cloud tutorial series
- AntonL1kesPotato
-
1000+ posts
Cloud Data Help
Please don't necropost.yesyou have to be a scratcherWith cloud variables.how do you do cloud variables?
- Discussion Forums
- » Help with Scripts
- » Cloud Data Help