question

Nykos avatar image
Nykos asked

Unity OpenTrade

Hi, my name is Nicolas, and i am new to playfab, actualy i am new to pretty much anything server related. I've been using unity for almsot six years and know it very well, having done many games.

Here's the deal: i've been trying to integrate openTrade i my current game, but i must be doing something wrong because nothing works.

Could someone be kind enough to explain me how do i call openTrade in unity?

I have set different items in my catalog, set them as tradable, for example their id is ItemCorn, ItemSugar, etc...

And i'm getting Error Code 1000, Invalid Param

Thanks in advance if someone can help me, i'm realy lost here.

 

Nicolas

10 |1200

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

Nykos avatar image
Nykos answered

 Hi, thanks a lot for your help, it's now working. I can open trades and find them with GetTrade.

Now i'd like to open the trades to other player ( obviously :) ) and so i understand i have to modify :openRequest.AllowedPlayerIds = new List<string>() { PfSharedModelEx.globalClientUser.playFabId };

This si the doc's definition:

"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."

So does it mean i have to put a empty sting array, or do i just erase the line and don't set allowedPlayerIds ?

 

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

Thanks for calling that out! The documentation is saying that if you pass in null for AllowedPlayerIds, any player can accept the trade, while if you pass in an empty array, no player can accept the trade. And in my own testing, I'm finding that the empty array code path is actually a problem, so I'm going to get that updated so that an empty array works the same as passing null for AllowedPlayerIds. For now, please only pass in null or an array with at least one valid PlayFab ID.

10 |1200

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

Nykos avatar image
Nykos answered

Hi, sorry for the delay, i wanted to try it alone. So everything concerning the trading system seems to work great. At least on PC, be cause i just can't test on mobile, i am having other issues, but i think it's a different topic so i will create a new post about that. But i really want to thank you for the help yo have provided with the trade system, thanks a lot.

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 quite welcome! The Trade API calls work the same regardless of which platform you're using, so once you're past the other issues you mentioned, you shouldn't have any problems with this.

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.