+ 1
How to store highest score of players who play my code?
8 Respostas
+ 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).
+ 5
What's your question?
+ 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.
+ 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.
+ 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
+ 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.
+ 1
Tibor Santa ok, thanks for information
+ 1