question

eliassanto avatar image
eliassanto asked

How do i set custom attributes in GrantCharacterToUser?

How do i set custom attributes in GrantCharacterToUser?

My character have the atributes Speed, Stamina, Material Index, and some others, what i want is something like this:

GrantCharacterToUserRequest request = new GrantCharacterToUserRequest() 

{  

   CharacterName = "Falcon",

   Speed = 10,  

   Stamina = 20  

};

Thanks, Att Elias.

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

·
eliassanto avatar image
eliassanto answered

I kind figure out how to do it, the problem is know im geting: Invalid input parameters

private void SetCharacterData(CamelData p_Data, string p_characterID) 

{  

  p_Data.playFabID = p_characterID;


  UpdateCharacterDataRequest request = new UpdateCharacterDataRequest()

  {  

     CharacterId = p_characterID,

     Data = p_Data.GetData(),

     Permission = UserDataPermission.Public 

 };


  PlayFabClientAPI.UpdateCharacterData(request, (result) =>  {  

       Debug.Log("Done");
  },  (error) =>  {  

      Debug.Log(error.ErrorMessage);  

  });  
}
4 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.

eliassanto avatar image eliassanto commented ·
p_Data.GetData(); //Returns a Dictionary<string, string>
0 Likes 0 ·
brendan avatar image brendan commented ·

Correct - the GrantCharacterToUser call doesn't take CharacterData as an input currently (though we can certainly look into adding it - I'll open a backlog item on that), so you would set it with UpdateCharacterData. In the call to that, you do need to also specify the PlayFabId of the user. I'm not sure what format your p_Data.GetData() returns, but if it's a standard JSON-style object, that should work fine once you have the PlayFab ID in the call. Can you give that a try?

0 Likes 0 ·
eliassanto avatar image eliassanto brendan commented ·

Thanks for the reply, just got na warning email the problem was that my dictionary had more than 5 key/value pair, im changing it to a single JSON string.

Thanks again.

0 Likes 0 ·
brendan avatar image brendan eliassanto commented ·

Ah,yes - that would do it. Let us know if you run into any other issues.

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.