Hello everyone,
I was using Javascript's Date object to manage time-based events in the Cloudscript. I came across an API called GetTime in the ServerAPI. I was wondering if it is necessary to call that API for time-based events? I would like to work with a time value regardless of server locations.
For example; when players create a group and do something in common (e.g. upgrading their HQ), will the time be different depending on who calls the ExecuteCloudscript API?
Let's say there are 2 players and they are in the same group (clan). One of them is from the USA, the other one is from Germany, and the upgrade process takes 30 minutes. If the player in the USA calls the ExecuteCloudscript API to start the upgrade process, will the player in Germany see that the HQ will be upgraded in 30 minutes? (Let's assume that the player in Germany logs in to their account right after the upgrade process is started and retrieves the time value that is saved in the database)
The player in the USA calls this API:
handlers.UpgradeHQ = function(args, context) { // ... var now = new Date().getTime(); // Add 30 minutes to the current time var endTime = now + (30 * 60 * 1000); // save 'endTime' to the database };
The player in Germany calls this API after 'UpgradeHQ' is called:
handlers.GetUpgradeTime = function(args, context) { // get that 'endTime' value from the database var now = new Date().getTime(); // Return the time difference in miliseconds var timeDiff = endTime - now; return timeDiff; };
The player in Germany should get a value ~1800000 (which is 30 minutes in milliseconds). In the other words, will the "now" variables be the same for the players from different counties?