Discuss Scratch

StarryDove
Scratcher
100+ posts

how to solve this issue??

so basically, we all know that lists dont save data and everything resets if you refresh. in my case i want to save the usernames of my game players in one list, and their scores in another- which get updated as their score increases/decreases.
how do i code this??
deck26
Scratcher
1000+ posts

how to solve this issue??

You'd have to encode usernames - the usual method is 01 for A, 02 for B etc (remember to also encode numbers) and use a separator like 00 between different usernames. That allows you to store mulltiple usernames in one cloud variable. It's probably easier to store the value for that user alongside the username. There's no need to encode the value if it's a whole number but best to give it a fixed number of digits to avoid needing another separator.

The main issues with this are
- cloud server reliability is very variable
- for a 10 character username you need 20 digits plus 2-digit separator plue their vlue (say another 5 digits) a single cloud variable can only hold
data for 10 or so users so you also have to use multiple cloud variables
- updating any score has to be done carefully, you need to make sure you've just read the relevant cloud variable and that if you change it you
check that it worked - you might have more than one user trying to update the variable
michaeljackson1365
Scratcher
500+ posts

how to solve this issue??

1. Encoding usernames (cloud data can only store numbers) which is very hard.
I might create an encode/decode method.
Encoding scores is actually really easy.
cute pfp~
StarryDove
Scratcher
100+ posts

how to solve this issue??

thanks!!

Powered by DjangoBB