question

brendan avatar image
brendan asked

timer

dragongamestudio
started a topic on Sun, 03 May 2015 at 11:53 PM

hello,

is there any feauture of cloud script to run timer, because i need it to do something like this scenario

  • Player A and Player B created matcmake and played in the room

  • one time player A just close the application/ uninstall it for some reason

  • and in Player B device the game still shown in his list, and player B doesnt know if player A uninstall it and not play it again, and because player B was very kind man, he still wait and hope player A will do his turn.

and what i would make with the cloud script is, to make a schedule to run a function in script to check if the room was not played for over 3 days, then the room will destroy, with objective to give Player B information if Player A hasnt do his turn for 3 days.

maybe playfab have some thing that ive didnt know yet to solve this, or some suggestion to solve this.

thank you :)

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

5 Comments
Brendan Vanous said on Sun, 03 May 2015 at 11:59 PM

In general, server-side logic must be triggered by an action taken by a player, a server, or an administrative tool. For your specific scenario, the best way to solve this currently is with a check triggered by the individual player. So in this example, when Player B signs in to check his games, there should be a check to see when the last move was made by the other player. If, after several days of inactivity, Player A is "disqualified", that should be triggered the next time Player B checks on his open games.

Brendan


dragongamestudio said on Mon, 04 May 2015 at 1:44 AM

thank you for your suggestion,

any way what is the javascript version that playfab use for the cloud script?


quirkster said on Mon, 04 May 2015 at 7:49 AM

I just did something similar, so remember to convert timestamps to a common format when you do the comparison. In cloud script, I added a variable to each newly created game...

var startTime = Date.now();

Then, when a player downloaded their list of games, I would compare startTime to a timestamp from the client, but had to match the format first...

//need to add check to remove stale invites
DateTime started = new DateTime(1970, 1, 1).AddTicks(game.Value.startTime * 10000);
if (started.AddDays(7) < TimeCheck.instance.OfficialUTCDateTime) {
//remove stale invite
}


Brendan Vanous said on Mon, 04 May 2015 at 11:52 AM

We use the latest V8 JavaScript engine, so we are fully ECMA-262 compliant.

For operations like this (where you need to check information for multiple games the player is in, in this case), I would recommend putting the key info on all the games into a single master Shared Group Data object, or a set of User Data values which can be queried in one API call. Many separate calls to query for each game would be highly inefficient, and if you have a delay on any return (often due to last-mile issues with the client), this could cause a delay in the game.

Brendan


dragongamestudio said on Mon, 04 May 2015 at 4:21 PM

ok thank you Brandan :)

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.