question

eric@begoodi.fr avatar image
eric@begoodi.fr asked

Some questions

1) My game needs a leaderboard based on groups of users (per country for example). Each player adds points to his country and the leaderboard show best countries. What would be the best way to do that ? Creating fake users ?

2) If I want to reset the leaderboard every week, what must I do ? Reset corresponding statistic manually for every player, or is there a better way ?

3) Is there a way to launch batches at a future date. For example a handler executes, and I need to run a function let's say 10 minutes later to verify something about the user and act accordingly...

4) Is there a documentation about all builtin handlers in the system ? Could not find it...

Thanks a lot for your answers :)

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

Happy to help:

1. Leaderboards are driven by statistics on users in our system, so while you could create a fake user and post statistics to it (using a Cloud Script call), you'd have many people performing this action simultaneously, stomping each others's writes. What it sounds like you really want is an aggregator which sums the points across everyone submitting a value - something akin to what you might have in a Clan system. We don't have support for that as yet, but we are planning to implement Clans in a future update, which would provide this.

2. You can set a leaderboard to reset every week by setting the VersionChangeInterval in the statistic definition. Here are the relevant API calls:

http://api.playfab.com/Documentation/Admin/method/CreatePlayerStatisticDefinition

http://api.playfab.com/Documentation/Admin/method/GetPlayerStatisticDefinitions

http://api.playfab.com/Documentation/Admin/method/UpdatePlayerStatisticDefinition

3. We should really get into the details of the gameplay component you have in mind, so that we can define the best solution. For example, we have the ability for Virtual Currencies to regenerate in our service. The current balance of a regenerating currency is not calculated every second for every player - that would be inefficient and excessively costly. Instead, it is recalculated every time it is needed (on purchase calls, inventory queries, etc.). For most titles, having a handler in Cloud Script that updates values when needed is the right way to go.

4. We have docs for all our API methods in our main documentation page (the links above). What are you looking for specifically?

10 |1200

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

eric@begoodi.fr avatar image
eric@begoodi.fr answered

Thanks a lot for your quick reply ;)

1) Yes, that's what I need, a clan leaderboard to see the best clans. I will wait for that feature, good !

2) Thanks, I missed that point !

3) It's for a 1 vs 1 game where both players have some time to make their move (20 sec), then the server calculates result of the move and send it back to both clients. Then they have again 20sec for next move, etc... It's not heavy realtime but not really turn based as they play simultaneously. I'm currently thinking on how I can handle with that. I think I will need Photon, but then as soon as the game has started, I want the server to calculate move results every 20 sec. independently of users, that's why I spoke about a process I can postpone. Hope I'm clear enough, and would be happy to have your advice on best practice for that.

4) I see that I didn't explain well. I make distinction between script that are called by client and scripts that are automatically triggered on some actions. For example script triggered out automatically before buying an item, or scripts triggered when user enters a photon room => Is there a list of these automatically triggered scripts ?

As you are here, I permit myself to add 2 more questions :

5) Is there a possibility to buy an item with other items (cards) ? I defined my cards as items to benefit of drop tables facilities (great functionality by the way), then these cards are used to buy another item (sword). When I create the sword as an item, it seems that the price can only be a currency and I would pay it with cards...

6) Is there a way to broadcast a message to some clients from a server script ? Seems obvious but I didn't understood how to do...

Thanks again,

Eric

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

Ah, I see. For 3, each player has 20 seconds to play a move. So one way to handle this would be to have both clients timing this. The player whose turn it is would get 20 seconds to make his move, while the player waiting on him to make a move would wait slightly longer - say, 21 seconds - and then call a Cloud Script handler to call for an update. That way, the player whose move it is gets the full time to respond, and if both players kick off their Cloud Script calls at the same time, the net result should be the same, since the player whose move it is should be getting back a "you waited too long" error. In all cases, you'll want to send back the "time remaining" on the current move, from the server's perspective. Don't make it a timestamp, but rather a time remaining, so that you're not affected by clock drift between different servers. The latency will cause the timers between the server and the client to be slightly off from each other, but being generous on the "20 second" timer will account for that.

For 4, you're specifically referring to the Photon Cloud webhook calls, then - understood. Those are documented, along with their parameters, in the tutorial on using Photon with PlayFab, here: http://api.playfab.com/docs/using-photon-with-playfab/

And for your new questions:

5. Correct - the prices need to be in real money or virtual currency. This sounds more like your need is for an alchemy or crafting type of system, where different items can be combined to create other items. That is on our backlog, so please do let us know if it's something you'd like to see (and feel free to add it to the Feature Requests forum, so that people can vote on it). It's not scheduled right now, but if it's something that many developers identify as a need, that would help to prioritize it.

6. You can send Push Notifications via Cloud Script, but it sounds like you're more thinking of a generic message queue, is that correct? One way to do this would be to have a Shared Group Data object per player, where you can have messages queued from others, though you would need to manage the case where a player doesn't sign in for a long time, causing the Shared Group Data to be at its limit (using the PlayFab ID of the player writing the message and rejecting new messages would be best, since deleting old ones and writing new ones could have issues with race conditions due to multiple people trying to write to the same Key at the same time). We also have a generic message queue in our backlog, so the same would apply here if you'd like to see this feature added in a future update.

10 |1200

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

eric@begoodi.fr avatar image
eric@begoodi.fr answered

3. In fact both players play simultaneously, no one has to wait for the other. For that topic, I will go deeper with Photon and see how I can handle with it. Thanks. Closed.

4.OK I see, these automatic triggered scripts are for Photon only. It leads me to another question but I will open a new thread. Closed.

5. That's right it's a kind of crafting, I will post it in the request forum. Closed.

6. By message I didn't meant a text message between players, but more something like an event. The client listen for an event, and a cloud script server can send this event to the client, and the client can have some code attached on this event and execute it. Kind of communication from server to client.

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

I see. No, apart from custom game servers, you're not pushing data from the server to the client. In services like PSN, there's a "heartbeat" type of message sent from the client to the service. The response from the service contains information like presence data on other users and whether there are any messages in the player's message queue. The system I described would work the same way - you would have a queue of messages for the user, and on a periodic "heartbeat" call, you would run a Cloud Script to check for outstanding information you need. In general, if you choose to go this route, the frequency of the heartbeat should be around one every 30 seconds or so.

10 |1200

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

eric@begoodi.fr avatar image
eric@begoodi.fr answered

OK thanks, that's clear.

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.