+ 1

How to store highest score of players who play my code?

13th Apr 2023, 11:31 AM
Raja Rawat
Raja Rawat - avatar
8 Antworten
+ 8
Raja Rawat each execution of the Sololearn playground is an isolated, sandboxed session that starts from scratch. You cannot persist any data in Sololearn during code execution. What you describe is only possible by utilizing an external database in the cloud, for example Google Firebase. There are providers that give some free quota, but generally these are paid services. And putting the code on Sololearn can expose your credentials or API keys, which is used to connect to the database. So there is a huge security risk for you, and you should only implement such a solution when you are absolutely clear about how to mitigate those risks (and avoid a huge bill from cloud services).
13th Apr 2023, 7:20 PM
Tibor Santa
Tibor Santa - avatar
+ 5
What's your question?
13th Apr 2023, 11:34 AM
Sakshi [Offline 🙃]
Sakshi [Offline 🙃] - avatar
+ 5
For all players, you would have to save the score somewhere in the internet, on a server or in a cloud. If it's just for the individual player, you could either store the session score or all of their high scores in a local storage cookie.
13th Apr 2023, 12:20 PM
Ausgrindtube
Ausgrindtube - avatar
+ 3
Do you think you can find the code again? Maybe you can see how they did it. My understanding is that Sololearn doesn't allow access to user's devices.
13th Apr 2023, 5:34 PM
Ausgrindtube
Ausgrindtube - avatar
+ 2
At what point of the implementation? Does high score persist from one run to the next? Is score local to the machine its on or anyone who plays it on any device? Just code wise, you should have some class that represents the player. Not sure if this is the right js language here, but just have a field for the score and a static variable for the high score. At game over compare the two and update if needed
13th Apr 2023, 1:08 PM
Bob
+ 2
Sakshi , Ausgrindtube & Bob Once I saw a code on sololearn where my score and others score was being saved. That's why I just want to know that if I want to do this then how can I do it.
13th Apr 2023, 5:10 PM
Raja Rawat
Raja Rawat - avatar
+ 1
Tibor Santa ok, thanks for information
14th Apr 2023, 3:00 AM
Raja Rawat
Raja Rawat - avatar
15th Apr 2023, 6:43 AM
Raja Rawat
Raja Rawat - avatar