question

jkcrescenzi avatar image
jkcrescenzi asked

Best practice for organizing player data

Hi, I asked this question a couple hours ago, which is still related to this current question, but my understanding has changed. Basically I threw all my player data into one object, which I wrap (seen below) for the playfab set objects request.

 var dataList = new List<SetObject>()
         {
             new SetObject()
             {
                 ObjectName = "PlayerData",
                 DataObject = CollectDataForSave() //returns a mock PlayerPayFabData object
             }
         };

My data objects are as follows:

 public class PlayerPlayFabData
 {
     public List<string> inventory;
     public List<CharacterData> allCharacterData;
 }

 public class CharacterData
 {
     public string id;
     public int level;
     public int xp;
    
     //loadout
     public List<AbilityUpgradeData> upgradeData;
     public WeaponLoadoutData weaponSlotOne;
     public WeaponLoadoutData weaponSlotTwo;
    
     //customization
     public string primaryColor; //hexadecimal
     public string secondaryColor;
     public string camoOptionId;
     public string emissionOptionId;
     public string headOptionId;
     public string chestOptionId;
     public string legsOptionsId;
     public string feetOptionId;
 }

 public class AbilityUpgradeData
 {
     public bool upgrade0; //aka ability unlocked
     public bool upgrade1;
     public bool upgrade2;
    
     public bool upgrade3a;
     public bool upgrade3b;
    
     public bool upgrade4a;
     public bool upgrade4b;
    
     public bool upgrade5a;
     public bool upgrade5b;
 }
    
 public class WeaponLoadoutData
 {
     public string weaponID;
    
     public string modOneID;
     public string modTwoID;
 }

This gives the error "Object PlayerData is 3543 bytes, the limit is 1000 bytes for title_player_account entities." Because I'm already exceeding the allocated amount of data with only three characters and three inventory items, this is apparently and obviously an inefficient method of storing data.

That said, I am unsure how to leverage the current systems to store this data in a manner that will not exceed the byte limit.

As an aside, I am very, very new to remote storage services and their associated APIs and SDKs. There is likely a very obvious solution which I am oblivious to.

entitiesCharacter Data
1 comment
10 |1200

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

jkcrescenzi avatar image jkcrescenzi commented ·

EDIT: here is the link to my actual previous post. rather than some other post I was just viewing at the time... https://community.playfab.com/questions/142919/how-to-associate-player-data-to-characters.html

1 Like 1 ·

1 Answer

·
Xiao Zha avatar image
Xiao Zha answered

Entity objects allow you to read and write small JSON-serializable objects attached to an entity. If you want to store large file for player, you may consider using Entity files - PlayFab | Microsoft Learn. In addition, PlayFab provides Character related APIs for you to manager Character’s data, you may refer to Character Data - REST API (PlayFab Client) | Microsoft Learn. The usage of the Character Data APIs is similar to the Player Data: Quickstart Player Data - PlayFab | Microsoft Learn. As for player inventory, you can refer to Using Player inventory - PlayFab | Microsoft Learn for information about the economy V1 inventory and PlayFab Inventory APIs - PlayFab | Microsoft Learn for information about the economy V2 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.

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.