question

brendan avatar image
brendan asked

Sending lives like Candy Crush?

Johnny
started a topic on Mon, 25 May 2015 at 6:16 PM

How do I store data for sending lives? I'm using facebook.

I have SQL background so i'm thinking of having a "Life Gift" table and populate it with recipient-sender id's. However, playfab API doesn't support that functionality with UpdateUserData. What are the alternatives? 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.

1 Answer

·
brendan avatar image
brendan answered

The best way to approach this would be using a system similar to the "confirmed friend" system described in this post:

https://community.playfab.com/questions/311/206710977-Check-if-one-friend-is-online-Accept-friend-request-.html

For this case, where you have "Life Gifts", you could simply have a Shared Group Data object whose ID is the player receiving the gift, and the players sending the gift would write a Key/Value pair in it of [TheirPlayFabId]/[Lives] - that would allow you to have the player giving the gift add more over time (if you allow that), though there would be the corner case of someone trying to give the player a gift from one account on two devices simultaneously, but that should be extremely rare, since it would require the two calls coming in simultaneously.

Upon login, the player receiving the gift would remove the other player's Key/Value pair, adding the lives to their total.

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

thanhvantle avatar image thanhvantle commented ·

could the Trading system be used to address this? could a player open a trade requesting an extra life but with the player sending the life not actually having anything deducted on their side?

0 Likes 0 ·
brendan avatar image brendan thanhvantle commented ·

@thanhvantle: Yes, we added the trading system since this discussion took place. At the moment, the way you could do this is by defining a Container in your game Catalog (so possibly selling it to the player), which contains the lives you want to trade. You could then make that Container part of a Trade.

0 Likes 0 ·
thanhvantle avatar image thanhvantle brendan commented ·

since players are able to send as many of these containers as there are trades requested, how does this get addressed? would you set the container price to 0? just wondering how I should be thinking about a player sending a container that they themselves do not actually "own".

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

So I've got a container set up called "life_extra" and in it is a single currency called "life_token". I OpenTrade requesting "life_extra" in exchange for nothing in return with a friend specified in AllowedPlayerIds. That friend who has plenty of the currency "life_token" attempts to AcceptTrade using the TradeID and OfferingPlayerId from the previous OpenTrade request. However, I keep getting the TradeAcceptedItemsMismatch error. Any ideas on what I'm doing wrong?

0 Likes 0 ·
thanhvantle avatar image thanhvantle thanhvantle commented ·

Should I be specifying the AcceptedInventoryInstanceIds? If so, how do I grab that for the "life_token" virtual currency?

0 Likes 0 ·
brendan avatar image brendan thanhvantle commented ·

The issue is that the player accepting the trade must specify the correct ItemId(s) in the RequestedCatalogItemIds parameter.

0 Likes 0 ·
thanhvantle avatar image thanhvantle commented ·

But there doesn't seem to be a RequestedCatalogItemIds parameter specified in the AcceptedTradeRequest class. I only see OfferingPlayerId, TradeId, and AcceptedInventoryInstanceIds. Sorry, still a bit confused here.

0 Likes 0 ·
brendan avatar image brendan thanhvantle commented ·

My apologies - what I meant was that the TradeAcceptedItemsMismatch error can only occur if the Trade specifies RequestedCatalogItemIds, and the AcceptedInventoryInstanceIds specifies in the call to AcceptTrade does not specify items that match the IDs in RequestedCatalogItemIds. If you want to specify a "gift", you need to set the items being offered up in OfferedInventoryInstanceIds in the call to OpenTrade, and RequestedCatalogItemIds should be empty.

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.