I am working on a multiplayer racing game, I am confused in order to think about this thing, in keeping players purchases, for example if a player purchases a car, how will I save the car in his database (I made a database in my server but I don’t know how I can save the purchased cars in Player’s table) Please help me by giving me an example, tutorial or something else
I think you can use this function
PlayerPrefs.Getint(“HasPurchasedCar”,int number)
When the player buy a car make sure to call this funcition:
PlayerPrefs.Setint(“HasPurchasedCar”,1)
And in the start function put it like this
Start()
{
If(PlayerPrefs.Getint(“HasPurchasedCar”,0)==1)
{
//car unlocked
}
I agree with @Algebrapixel , simplest way would be, to save it locally by using PlayerPrefs.
Or you could create your own “file system” like e.g. described here .
But if you need an online database solution, maybe using Firebase is the simplest approach:
Here is a full video tutorial about that approach.
If you already have your own database, you can still use the approach from the video above, but adapt it a bit so that you can use your individual database by sending Request to it. This video describes it in a bit more detail.
Hi @Algebrapixel ,
Thanks for you reply
I think that the save does not continue if the player deletes the game and downloads it to another device again, he will lose all his purchases in his account, so I want to save all purchases in the player’s database in my server