question

Muhammad Roshaan Tariq avatar image
Muhammad Roshaan Tariq asked

Get Specific PlayerId from Segments in a Scheduled task for Cloudscript parameter

Hi,

I have functionality which I want to implement in my game which is reward every user 100 coins after a week.

And when they get the reward I want them to be notified in the game that they got 100 coins from system. Now for notifying them I don't want to use Push Notifications as I want them to be notified in game on UI.

My idea to implement this on server:

  1. Create a scheduled task
  2. Select "Run actions on each player in a segment option"
  3. Select "All Players" for segment
  4. Add Two actions
    1. Award a container to user
    2. Add a message in user's readonly data by adding another action for executing cloudscript. And using server.UpdateUserReadOnlyData I can save the message in each user profile. But I cannot find a way to send the PlayerId which I got from Segment to my cloudscript.

And on Client side:

  • Check for messages in the read only section every time a user log-ins or after every minute incase if they are already logged-in and the system rewards them.

Is this implementation good? If not, how can I implement this feature?

CloudScripttasksscheduled tasks
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 can get the PlayFab ID for the user from the Content for the script, but I really wouldn't recommend that, as this would have you generating meter usage (and so, cost) for players that are no longer playing your game. If you want to entice users to come back, I'd recommend reading through our LiveOps Guide for suggestions on re-engagement campaigns. https://blog.playfab.com/blog/the-playfab-guide-to-liveops

The way you've described this feature, there's no offline notification sent to the user, so really, you only need to determine what they should receive when they sign in. So I'd use an "OnLogin" script in Azure Functions Cloud Script to check when the player last signed in and was rewarded, and so give them any applicable rewards.

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

Muhammad Roshaan Tariq avatar image Muhammad Roshaan Tariq commented ·

@Brendan Is there any way I can get only active players in cloudscript?

0 Likes 0 ·
brendan avatar image brendan Muhammad Roshaan Tariq commented ·

Can you describe your use case in more detail? You can define a segment based on the time since the last login, or you could write a timestamp value to a statistic to create a leaderboard of most recent logins. But depending on what you want to do with that information, Cloud Script may or may not work for you.

0 Likes 0 ·
scottcartier avatar image
scottcartier answered

I posted in the Discord, but am wondering the same thing as the OP.

"You can get the PlayFab ID for the user from the Content for the script"

If you mean the context, then I don't see it. The ScheduledTaskFunctionExecutionContext object does not include the current player id the same way that FunctionExecutionContext does. Unless I'm missing something?

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.