question

Marc avatar image
Marc asked

Is there a way to trigger a PlayStream Action when a specific item is consumed?

Hi,

I'm trying to fit a matchmaking system on playfab without uploading a custom server.

The idea is to use a mix of Shared data for ELO ranges and Segmentations to trigger some events depending on statistics values.

For example:

First to know, I have ELO (1-5000) and SHIELD (0/1) statistics.

A player reach ELO 126 from a previous ELO 120 value, then the Segmentation range_110_125 that look for this statistic changes, triggers an event that runs a cloudscript function that remove the player from the SharedDataRange_110_125 and at the same time another Segmentation range_126_150 triggers and add this player to the SharedDataRange_126_150.

(in our game, the ranges are defined and finite)

Also, I need to add a Shield factor, that prevents attacks from another player. That Shield factor will be a consumable item by the time (12h for example) and will set the statistic SHIELD to value 0 or 1.

My question is:

In the PlayStream Actions, ¿can I execute an action when a specific item from the catalog is granted or consumed? (the shield in this case) So, when a shield item is granted/consumed, the SHIELD statistic will set to 1/0. And a another Segmentation trigger looking for SHIELD stat value changes, will remove/add the player to SharedDataRange_XXX_YYY.

 

Marc

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

Yes, you can trigger a PlayStream Action based upon anything that can generate an event, and inventory actions do create events (you can also use custom events via the Write...Event API calls). Unfortunately, Shared Data is not a good solution for this. It is meant for subsets of your user base to be able to share data - think on the order of 100 people. Even with dividing your player base up by ELO ranges, for any non-trivial user population, you're going to exceed that quite quickly. Having too many players trying to read from those data spaces at the same time will then not be viable.

However, one thing you could do is write a statistic for the player's ELO rating. You could then set it to 0 while the shield is on, and to the correct value when the shield is off. Then, you could use GetLeaderboardAroundUser to get a range of players with skills around that of the current player, and randomly pick one to use for matchmaking.

10 |1200

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

Marc avatar image
Marc answered

Thank you Brendan.

I'll do in that way.

Still I don't understand the way PlayStream Actions work. I see in the dashboard, that you can trigger an Event "com.playfab.player_consumed_item" and assign it to an action (a CloudScript function in my case). But, ¿how this function knows the id of that item consumed (or granted)? I've been looking for examples, but I didn't found anything yet.

In my case, if a "shield_12h" item is consumed (by time or manually), I need to set the statistic SHIELD to 0. So other players can found and fight him.

Marc

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

The events coming into PlayStream have all the info needed to act upon them - we'll be adding all the events and their parameters to the docs shortly. In the case of the player_consumed_item event, for example, if you click on the event to see its details, you'll see that the event includes the ItemId and UsesRemaining (after consuming however many were just consumed from it), for example.

 

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.