- Home /
Consumable (IAP) items
Hello!
I'd like to create a consumable item that you can gain in the game and also purchase through the in-game store. I think PlayerPrefs wouldn't work since the users lose all their consumables if they delete the app.
How have you implemented purchasable consumables to your games? I tried looking for tutorials on Youtube but couldn't find any.
The way I'd do it with PlayerPrefs:
public void ConsumableButton()
{
if (PlayerPrefs.GetInt ("ConsumableAmount") >= 1)
{
ConsumableEffect();
ConsumableAmount--; //what is the opposite of '++'?
PlayerPrefs.SetInt ("ConsumableAmount", ConsumableAmount);
// Only usable once per level
consumableButton.GetComponent<CanvasGroup>.interactable = false;
}
}
Thanks in advance!
I think if you want to put something in the game, that shoud not be deleted, when the game is deleted, then you shoud store that information somewhere on a server and assign it to the player userName (GameCenter username or in game userName)... Other Option is to make it with iAP (If it's android or iOS), then the player can restore purchase...
Does Apple provide a way to store the information on their servers?
The other option seems to not work in this case, since consumables shouldn't be restore-able(?)
with iOS you can make several type of iAP's. Consumables and Non Consumables. The non Consumables can be restored, the consumables cannot be restored.... I think you can use iCloud to store some information but not realy sure, maybe you can check in the documentations.. Or somebody more experienced coud answer..
If the player deletes the game and has previously purchased consumables that are still unused, should they be stored in case the user returns or is it the user's own fault that the consumables disappear when he deletes the app?
No. PlayerPrefs is the worst way to store consumables. They are the least secure. You might want to use encrypted PlayerPrefs or binary files at least to make it secure.
Your answer
Follow this Question
Related Questions
Saving a list of items 1 Answer
How to save an item as bought in player prefs? 0 Answers
PlayerPrefs on gameObject 1 Answer
Saving and Re-calling Remove Ads Functionality *Newbie!* 0 Answers
How to handle IAP refund in iOS? 0 Answers