question

ravio avatar image
ravio asked

How to use Shared Group Data to send gift (For eg. Life) to other players?

Hi,

I am new to playfab and i am implementing playfab with unity to manage my inventory.


How to send a gift randomly to other players using shared group data?

I tried to implement Gift functionality using Trading system but it needs other player playfabid.

And How actually GetTradeStatus work when other user get gift from player one. I am getting this error while fetching status TradeDoesNotExist.
Please clear my doubt regarding the same. Or if you can provide me any sample example of gift sending and receiving between two users.

Shared Group DataTrading
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

·
brendan avatar image
brendan answered

I would recommend using the Trading system, as trying to use a data system for this is going to result in lost items and item duplication cheats. What is your scenario? Why is player 1 unable to get the PlayFab ID of player 2 in your case? Can you give us the Title ID, PlayFab IDs you're testing, and the Trade ID of an trade you created?

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

ravio avatar image ravio commented ·

Hi,
For Opening Trade, I am doing this
PlayFabClientAPI.OpenTrade(newOpenTradeRequest{

OfferedInventoryInstanceIds =newList<string>{ "extra_life" }

},OnOpenTrade,OnTradeFailed);

Id of trade item is "extra_life".

And in other player i am checking

PlayFabClientAPI.GetTradeStatus(newGetTradeStatusRequest{
OfferingPlayerId = playfabid,
TradeId = "extra_life"
},OnExamineTradeSuccess,OnExamineTradeFailed);

But it always going into OnExamineTradeFailed method. And Just let me know how i can list all the players who open trades? And how i can accept that?

Thank You.

0 Likes 0 ·
brendan avatar image brendan ravio commented ·

The Trade ID isn't the ID of the item you're offering in the trade. It's a unique ID that's generated to reference the trade (which can contain multiple items, to be clear). Since you're not specifying a recipient for the trade, it sounds like the intent is for anyone to be able to accept it - is that the case? What is your current design for how you send information about the trade to other players?

0 Likes 0 ·
ravio avatar image ravio brendan commented ·

How other players can get that player 1 open the trade or sent a gift to them?
Actually i change the design patter just now, I am getting other players playfabid using this,

PlayFabServerAPI.GetPlayersInSegment(newGetPlayersInSegmentRequest(){
SegmentId = SegmentIdForAllPlayers
MaxBatchSize = 5
},OnPlayerDataFetched,OnPlayfabError);

And Storing their id in one list after that i create list of players and Opening Trade,

public void GiveItemTo(stringa_otherPlayerPlayFabId)

{
PlayFabClientAPI.OpenTrade(newOpenTradeRequest{
AllowedPlayerIds =newList<string>{a_otherPlayerPlayFabId},
OfferedInventoryInstanceIds =newList<string>{

GetPlayerItemById(Constants.EXTRA_LIFE).ItemInstanceId

}
},OnOpenTrade,OnTradeFailed);
}

Now i want to know whether player 2 get the gift or not? How i can do that? Please guide me on that.

Thank you.

0 Likes 0 ·
Show more comments
ravio avatar image ravio commented ·

Hi Sir,

I just need to send Life to other player using Trade System.
I am fetching only 5 players using GetPlayersInSegment. And When click on life button a popup open with that 5 Players whom he can sent Life. And On button send i open the trade using OpenTrade method with playerplayfabid and itemInstanceId. And It give me success of trade open. Till this is done.

Now my problem is,

How other player will notify or get to know that player 1 is sent a gift to him? There is no API which is give the details of player 1's Open Trades details for player 2.

I just need to know how player 2 will know that player 1 Open Trade or sent gift to player 2.

Thank you.

0 Likes 0 ·
brendan avatar image brendan ravio commented ·

The number of players you're trying to retrieve isn't relevant - the API call in question always does a full re-evaluation of the segment, which is why it cannot be called frequently and must never be called as a result of a client action. What is the top-level design goal, here? Could you, for example, use leaderboards instead, to pick a player to send the lives to?

As to how player 2 would know, you would need to update that player's user data, so that when they log in, they can check that to see if there were changes.

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.