Best practices for saving high score, and also inventory for shop?

I am seeing conflicting things in regards to whether PlayerPrefs is secure/good enough. Should I use it?

All I am trying to save is a high score, and inventory amounts for certain items. The game is an endless runner, single player game.

Is PlayerPrefs fine for this?

Yes. For a purely single player game the last thing you should worry about is whether someone wants to cheat.

1 Like

Really? For a single player endless runner? Alright then, thanks :smile:

For a multiplayer game or game with connectivity like Candy Crush, is that when PlayerPrefs is not recommended?

EDIT: What about for an in game shop? Would that be saved in PlayerPrefs? Or not?

Is it a real-money shop? Like, I send you $1 and you give me 20 Gems kind of thing? In-app purchase, in other words?

If it’s that, then no, PlayerPrefs alone will be no good because the player will be financially incentivized to cheat (which is relatively easy). Plus in-app purchase always relies on a server; there is money-handling, the platform your on demands its cut, etc.

But if it’s strictly an in-game thing, like by grinding I collect 20 in-game coins with which I can purchase an in-game hat or whatever, then as @Ryiah says, don’t worry about it. Use PlayerPrefs because it’s nice and simple. If somebody wants to hack it, presumably they’re doing that to increase their enjoyment of your game, so what do you care?

1 Like

In-app purchases. Real money is what I’m using. Thanks for clearing that up.

So would I use playerprefs for the high score, but then something else for the shop since it’s real money, correct?

If that’s the case, would I use for the shop? I heard of binary serialization (which I heard is dangerous…) and I have heard of JSON but what’s the recommended best practice?

Server-side storage with a service like PlayFab. Anything you store on the device regardless of the technique you use can be hacked.

3 Likes

Alright, thanks for the helpful tips. Do you know any tutorial that shows how to implement this?

@JoeStrout and @Ryiah , so Unity IAP will obviously handle the real money, but I still need the PlayFab server to store and save the coins correctly, Right?

And what about the inventory of said items to buy stuff with, is that also tied with PlayFab?

Should I also use a service like PlayFab for storing high scores, especially since I plan to have a leaderboard?

A link would be much appreciated.

Bumping again: Is CloudScript NEEDED?

Bumping again: Is CloudScript NEEDED?