question

Daniel Buckley avatar image
Daniel Buckley asked

How can I open a trade in cloud script?

In Unity, i've set it up so players can create a trade. This executes a function in the cloud script. The problem though, is that it's saying entity.OpenTrade is not a function. I'm just wondering how i'd be able to open a new trade in the cloud script.

CloudScriptTrading
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

·
Citrus Yan avatar image
Citrus Yan answered

Hi, I have checked the PlayFab Docs and reproduced your issue, it seems that Trading APIs are Client APIs, it’s called by players who want to make a trade with others. For example, there are three parameters in the OpenTrade API request body:

  • AllowedPlayerIds: Players who are allowed to accept the trade. If null, the trade may be accepted by any player. If empty, the trade may not be accepted by any player
  • OfferedInventoryInstanceIds: Player inventory items offered for trade. If not set, the trade is effectively a gift request
  • RequestedCatalogItemIds: Catalog items accepted for the trade. If not set, the trade is effectively a gift.

As I understand it, the player who wants to make a trade is not listed in the parameters field. It indicates that Trading APIs are applicable from the Client’s side, not in the CloudScript, you may need to open a new trade and handle it on client’s side.

Here is the doc you may want to refer: https://docs.microsoft.com/en-us/rest/api/playfab/client/trading?view=playfab-rest

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.