question

brendan avatar image
brendan asked

How to manage characters and their inventory

Question from a developer:

I'd like more info on using characters - my first 2 questions are :

1. How to create a character (I can't see any add option in characters tab)
2. How to manage specified character's 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.

brendan avatar image
brendan answered

You can create a character on a user via the Server API call https://api.playfab.com/Documentation/Server/method/GrantCharacterToUser​ or by selling/granting to the player an item which is defined as being able to grant a character, and then using the https://api.playfab.com/Documentation/Client/method/GrantCharacterToUser​ API call. The former grants regardless, while the latter requires the item, so that players can't cheat the system with a hacked client and get characters without going through the normal game flow.

Item management for characters is done via the item management API calls for characters (https://api.playfab.com/Documentation/Server#Player%20Item%20Management​).

10 |1200

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

Stanislaw Gromadowski avatar image
Stanislaw Gromadowski answered

Hi,

Ok, lets say We want to create character from our game vial Client API. 

What should be the flow for creating character ? - My guess is -

1. Create a catalog with characters able to grant e.g. "Characters"

2. Create new item in there - name it e.g. "NormalCharacter" with marked option "Is a token for character creation"

3. When player calls "GrantCharacterToUSer" with this item's ID - a character will be created.

 

Now - Is there a way to check specified character's inventory and dedicated data from Client API ?

Lets say I have one character named "John" and I want to make API call to load his inventory and data from Client api.

How should such a call look like ?

 

Correct me if I'm wrong.

Thanks,

Stan

 

 

 

10 |1200

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

brendan avatar image
brendan answered

The system is designed so that a client can't add a character without the title being in control in some way, as that was a requirement from developers looking to use this feature when we created it. To create a character from the client, there are two valid routes.

The first would indeed be by creating a token in the game catalog that the player can purchase (with real money or virtual currency), which is used to grant a character from the Client API set.

The other would be to write a Cloud Script which calls the Server API method to grant the character instead, as that one doesn't require an item.

Now, for getting the inventory and data, we have a number of API methods available, but if you want to get both the User Data (or User Read Only Data) in addition to the player's inventory, the most convenient API method to use would be: https://api.playfab.com/Documentation/Client/method/GetUserCombinedInfo.

10 |1200

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

Stanislaw Gromadowski avatar image
Stanislaw Gromadowski answered

Thanks You for those answers !

 

Just to clarify,

 

1. If I create a character from pure client (no server api), I just need to buy a token item with "PurchaseItemRequest" or do i need any other calls too ?

2. How to distinguish if I want to load player inventory or specific character's inventory ? Where should I specify that ?

 

10 |1200

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

brendan avatar image
brendan answered

You're very welcome - these conversations in the forum help to make sure others with similar questions can quickly get their answers. :)

For 1, yes, if you want to do this entirely from the Client (no granting of characters or inventory), you would put an item in your catalog which is flagged as a character token, then purchase that from the client using a PurchaseItem call.

For 2, there are separate API calls for getting the Player's inventory versus a Character's:

https://api.playfab.com/Documentation/Client/method/GetUserInventory

https://api.playfab.com/Documentation/Client/method/GetCharacterInventory

10 |1200

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

Stanislaw Gromadowski avatar image
Stanislaw Gromadowski answered

Ok, thanks for clarifying these !

My next 2 questions are:

1. Is it possible to keep unique character names for all players for my title ?

2. Can my characters have their separate friend list in playfab db or is it just bound to the player ?

 

Thanks !

10 |1200

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

brendan avatar image
brendan answered

> 1. Is it possible to keep unique character names for all players for my title ?

Usernames and Title Display Names are unique per title. As stated in the docs for the GrantCharacter... API calls, the CharacterName is non-unique.

> 2. Can my characters have their separate friend list in playfab db or is it just bound to the player ?

The friend list is connected to the player's account.

10 |1200

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

adoyon avatar image
adoyon answered

Hi!

If I use automation in the playfab admin, does the item are automatically added to a default or active character?

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.

brendan avatar image brendan commented ·

Can you clarify what you mean by "the automation"? You can use a PlayStream Action trigger, for example, to add some items via Cloud Script when the player_added_title event occurs. That would be an effective way to add items to all players when they first sign into the game.

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.