Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » How to: Use save data using Scratch Accounts
- Loudlyz
-
Scratcher
2 posts
How to: Use save data using Scratch Accounts
Put your ideas below!
To help others in need!
To help others in need!
- MrKingofScratch
-
Scratcher
100+ posts
How to: Use save data using Scratch Accounts
This is very hard to do without someone always online. (people's data will get overwritten by new users)
While I can't give you a step by step tutorial, here are some basic steps you could follow:
If you want to do it with an account always online, you can store everyone's data in a list on that one account (maybe it's an alt of yours that you check for with the username block). I'll call this the “storage account.” alternatively you could have active players store the data, but when there's no one online, old data will get erased.
Whenever you want players to “save” set their save code to a cloud var called UploadUserData (if it's larger than 256 characters you must split it into chunks)
-You can encode usernames to the list with this
Create a list in the storage account.
If the UploadUserData var changes, check if the user who sent it has data in the list already
If so, replace it with the new data, if not add it to the list
Make a cloud variable called DownloadUserData and set it to a 256 chunk from the list (or you could do one user's data) every .1 seconds
When a player joins, ask them if they're new or if they already joined.
If they're new, start the game
If they've already joined, wait until the DownloadUserData var has their data, then take it (and from there you can split the save code into the vars or whatever you want to do with the save code)
————————————————
I made this in like 2 mins, so if you don't understand something or if I made an error, please let me know.
While I can't give you a step by step tutorial, here are some basic steps you could follow:
If you want to do it with an account always online, you can store everyone's data in a list on that one account (maybe it's an alt of yours that you check for with the username block). I'll call this the “storage account.” alternatively you could have active players store the data, but when there's no one online, old data will get erased.
Whenever you want players to “save” set their save code to a cloud var called UploadUserData (if it's larger than 256 characters you must split it into chunks)
-You can encode usernames to the list with this
Create a list in the storage account.
If the UploadUserData var changes, check if the user who sent it has data in the list already
If so, replace it with the new data, if not add it to the list
Make a cloud variable called DownloadUserData and set it to a 256 chunk from the list (or you could do one user's data) every .1 seconds
When a player joins, ask them if they're new or if they already joined.
If they're new, start the game
If they've already joined, wait until the DownloadUserData var has their data, then take it (and from there you can split the save code into the vars or whatever you want to do with the save code)
————————————————
I made this in like 2 mins, so if you don't understand something or if I made an error, please let me know.
Last edited by MrKingofScratch (April 4, 2024 02:58:24)
- Johnnnnnn_1111
-
Scratcher
6 posts
How to: Use save data using Scratch Accounts
when [ thank you very much v] key pressed
- Discussion Forums
- » Help with Scripts
-
» How to: Use save data using Scratch Accounts