question

Yusuf Demir avatar image
Yusuf Demir asked

Need more storage for inventory item data value

Hi,

We have a car simulation game. Player can buy cars from store. Every car is an inventory item. We are present a lot of customization features for cars that player have.

Here are a few of these features:

- Change color of car body,

- Change wheel,

- Change color of windows,

- Change/Add spoiler,

- Upgrade brakes, engine, gearbox, suspensions etc.

- Add up to 50 sticker to body of car.

Each sticker that added to body of car have a lot of data variable like position, rotation, scale, color etc.

All the customizations items can bought once for each car, for example; if a player bought wheel0 and wheel1 for his own car, then he can apply either of these two wheels to the car at any time without reboughting wheel0 and wheel1.

So basically the questions are :

1-) If I add this customizations data to each car inventory data, then will limits prevent this? (Inventory item data value size)

2-) If I create inventory items for car customizations data, then how can I connect them to car inventory item? All the customizations items can bought once for each car but some cutomization items like wheels and spoilers are common items in many cars.

3-) Do you have any suggestion about the structure for this system? (For Playfab side)

apisIn-Game EconomylimitsdataPlayer Inventory
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
Sarah Zhang avatar image
Sarah Zhang answered

>> 1-) If I add this customizations data to each car inventory data, then will limits prevent this? (Inventory item data value size)

This limit means the maximum custom data of one inventory item instance can’t exceed 100 bytes. It the value size doesn’t exceed this limit, it won’t be prevented.

>>2-) If I create inventory items for car customizations data, then how can I connect them to car inventory item?

To connect customizedaccessory items to car items, you can directly include the accessories’ inventory item instance Id in the car's inventory item custom data. And if the accessory item has the customizations data, such as the colors, you can store the customizations data in the accessories’ inventory item instance custom data. If so, you can call the client API – GetUserInventory to get the all inventory items and their custom data, handle and store the API result locally, then display the appearance for cars according to the associated inventory item’s custom data.

>> All the customizations items can bought once for each car but some cutomization items like wheels and spoilers are common items in many cars.

PlayFab doesn’t support configuring a catalog item that can only be purchase once by per player. You can check this thread - https://community.playfab.com/questions/860/210169488-Can-items-be-set-to-only-be-purchased-once-.html for more information. As this thread said, to prevent the player purchase some item multiple times, a simple workaround is to directly don’t display the item in the purchasable item list or disable the corresponding purchase buttons for players that have purchased the item. Using this workaround, the hack clients could still purchase more than one, but if it doesn’t cause an imbalance issue in your game, you can ignore them. For example, if you uncheck the [Is tradable] option, the player can’t sell it to others.

>> 3-) Do you have any suggestion about the structure for this system? (For Playfab side)

I think you can consider setting up the cars, accessories, and stickers as separate items instead of adding all customization data to car items. If so, you can store player modifications to each inventory item in their own custom data and let players get complete data by nesting read inventory items' custom data, so you will need less storage size of every inventory item’ custom data. Besides, we would recommend you host your server-side logic on the PlayFab CloudScript using Azure Functions, such as calling the server API UpdateUserInventoryItemCustomData to update the inventory item custom data. Players can call the API ExecuteFunction to trigger a function’s execution. You can use this method to confirm if the player’s editing operations are valid and store the editing results to the inventory item custom data.

2 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Yusuf Demir avatar image Yusuf Demir commented ·

@Sarah Zhang

>> "" To connect customizedaccessory items to car items, you can directly include the accessories’inventory item instance Id in the car'sinventory item custom data""


As I explained above, we have too much accesories items for cars. For example; a player can add 30 stickers(decal) to car. Each sticker will be a inventory item on PlayFab side. As you said above, I need add those sticker inventory item instance ids to car inventory item custom data. But each sticker inventory item instance id length is 16(e.g: F112E333B7259C44), so 16 bytes will be spent for each sticker I added to the car item inventory custom data. If custom data limit is 100 bytes, then I can only connect 6 sticker item to a car? Am I correct?

0 Likes 0 ·
Seth Du avatar image Seth Du ♦ Yusuf Demir commented ·

The limit of "100 bytes custom data limit" indicates that the maximum value size of a key, but PlayFab doesn't limit the numbers of keys (KVP).

It's ok to have multiple KVPs in custom data. But as it is also stated in the limit page, you may only update 5 KVPs within one API request.

Besides, compared with the current solution. I also suggest simply store a mapping JSON data in Player Data for more convenient references.

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.