question

dean-1 avatar image
dean-1 asked

Grant items to a character without server api?

Hi,

We're building an RPG and are using 'Characters' from PlayFab.

When a player loots a vase or rubbish, they find items - how do I then tell Playfab they've found these items? All I can find is 'GrantItemsToCharacter' but it uses the ServerAPI which is a red flag to use from all the comments I've found as it exposes the secret key.

Am I missing something obvious here? I know I could also do a single purchase item and loop through it but that seems really unnecessary.

Thanks.

apisIn-Game EconomyCharacters
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.

1 Answer

·
Gosen Gao avatar image
Gosen Gao answered

You can implement a method to grant items to character in CloudScript. And then use Client API ExecuteClientScript to execute it. And you don’t need to worry about exposing the Secret Key. Because CloudScript methods have full access to PlayFab's Server API set by default. Here is the CloudScript quickstart.

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.

dean-1 avatar image dean-1 commented ·

Thanks for the response, I implemented this but now get a 500 internal server error. Any idea why?

0 Likes 0 ·
Gosen Gao avatar image Gosen Gao dean-1 commented ·

The 500 error means that an error occurred which isn't expected. Could you tell us in which step you got this 500 Internal Server Error? Is this error returned by ExecuteCloudScript API call, or is it from GrantItemsToCharacter? What you passed in and what you got in response?

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.