question

julianscott avatar image
julianscott asked

Game Events

My game has Gameplay Events which are defined server-side (with a bit of JSON in TitleData). These events are basically 'collect X items'. They need to be simple to set up on the server.

What I tried is this:

A Scheduled Task checks TitleData.. it decides when an event becomes active (send them a notification), when it completes, etc. [WORKING]

Clients read TitleData. This tells them which items to collect in-game. They update a statistic (which is named in the TitleData). [WORKING]

Server script, when an event is complete, needs to run through all players, decide whether they have collected enough items, and if they have, it awards them an Inventory Item.

This is the bit I'm struggling with. I have another Task which runs a script on all players, and gives them Inventory Items (that's fine). But I don't seem to be able to run that task from a cloud script. (Reference Error: admin is not defined).

Am I on the right track with this? It does seem a little overcomplicated for what I want to achieve. Should I be using Rules for this?

Thanks,Julian.

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

·
pfnathan avatar image
pfnathan answered

Acutally, yes, you could just do "Rules."

Rule -> com.playfab.player_statistic_changed -> CloudScript goes and does the load to see what stat to check, compares it to the required amount, this will do the trick.

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.

1807605288 avatar image 1807605288 ♦ commented ·

"Decide whether they have collected enough items"
This is really the key statement of whether rules will work or not.

If you use a statistic to determine this condition, then YES, awesome, rules will work.

If you are using inventory items, then I would say it involves more work, and becomes less reliable, and generally doesn't work as well with rules.

Any time your thoughts move towards "do something for every player in the game" you should be very concerned. Conceptually, this kind of thought is the places where games don't scale. Your logic will work great in any pre-release test you do, and will fail spectacularly when released.

Building a rule that says "when a player statistic gets to 100[%], call the FinishEvent() Cloud Script for that player" works much better, because the LOGIC applies to one player, and you never end up saying "do something to every player". The DOWNSIDE to this, is that it will only ever apply to active players. At scale, you have to just take on this inconvenience, and accept that in-active players don't get touched.

1 Like 1 ·
julianscott avatar image julianscott commented ·

OK great thanks. I can't create a rule from Cloudscript though can I?

(also why am I getting this: "Title is over the limit of 3 for ActionTriggerCount. No more can be created until some are deleted." when I have no triggers defined https://www.screencast.com/t/YsaXnt95l)

0 Likes 0 ·
brendan avatar image brendan julianscott commented ·

The problem with that notion is that you'd be trying to create a Rule or Scheduled Task from a Client-triggered Cloud Script, which clearly isn't an option (otherwise, you'd be trying to create thousands or even millions of Actions/Tasks).

But specific to the error message you're seeing, all Actions count towards the limit, including Actions on Segment Enter/Exit, Rules, and Scheduled Tasks.

0 Likes 0 ·
julianscott avatar image julianscott commented ·

I was thinking about trying to create a rule from admin API. So that I can do a 1-click 'setup event' type thing, rather than manually creating a bunch of interracting different things in the dashboard. Just for automation, really.

0 Likes 0 ·
brendan avatar image brendan julianscott commented ·

Yes, we''ll be providing more API calls to mirror functionality in the Game Manager going forward. Obviously, it's not something that exists in the service right now, but we do aim to be API-first going forward.

0 Likes 0 ·
julianscott avatar image julianscott brendan commented ·

Great,thanks.

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.