สวัสดี ต้องขออภัย แต่เราให้บริการช่วยเหลือเป็นภาษาอังกฤษเท่านั้น
[Hi. Apologies - but we only provide support in English.]
bitHeads employees
สวัสดี ต้องขออภัย แต่เราให้บริการช่วยเหลือเป็นภาษาอังกฤษเท่านั้น
[Hi. Apologies - but we only provide support in English.]
You are welcome. Thanks for the suggestion!
You can schedule a cloud code script to run at a specific target time (as shown in the example below, which will execute at 23:59 every day), instead of adding a certain amount of time to the script's execution time.
"use strict";
function main() {
var response = {}
bridge.logDebugJson("Script Inputs", data)
const scriptName = data.scriptName
const interval = data.args.interval
const searchSpan = interval < 60 ? 60 : 60 * 24
// schedule checking and re-schedule itself for the next week at 23:59 on the same day
var scriptProxy = bridge.getScriptServiceProxy()
var dateTimeSpanMinsFromNowInMillis = new Date().getTime() + (searchSpan * 60 * 1000)
var result = scriptProxy.getScheduledCloudScripts(dateTimeSpanMinsFromNowInMillis)
var nowTime = new Date().getTime()
if ((result.status == 200) && (result.data !== null)) {
for (var i = 0; i < result.data.scheduledJobs.length; i++) {
if (result.data.scheduledJobs[i].scriptName === scriptName && result.data.scheduledJobs[i].scheduledStartTime > nowTime) {
scriptProxy.cancelScheduledScript(result.data.scheduledJobs[i].jobId)
}
}
}
const targetHour = 23
const targetMinute = 59
const minutesDifference = getMinutesDifference(targetHour, targetMinute)
let minutesFromNow = minutesDifference + interval
bridge.logInfo(`minutesFromNow between the script calling time and the time of 23:59 on a same day${minutesFromNow}`)
response.scheduleJob = scriptProxy.scheduleRunScriptMinutes(scriptName, data, minutesFromNow)
// the code for your script
return response
}
function getMinutesDifference(targetHour, targetMinute) {
const now = new Date()
const targetTime = new Date(now.getFullYear(), now.getMonth(), now.getDate(), targetHour, targetMinute)
const differenceInMilliseconds = targetTime - now
bridge.logInfo(`differenceInMilliseconds between the script calling time and the target time: ${differenceInMilliseconds}`)
const differenceInMinutes = Math.floor(differenceInMilliseconds / (1000 * 60))
return differenceInMinutes
}
main()
The parameters for this script will be 1440 minutes,
{
"scriptName": "thisScriptNameItself",
"args": {
"interval": 1440
}
}
Hi Lee,
We hear you. I'll raise it with the devs.
Paul.
No problem! glad to hear that.
Could you zip your project files to Google Drive and share them with us?
Please refer to this article for the details of those settings on the server configuration page -- https://help.getbraincloud.com/en/articles/9153860-design-servers-my-servers
It looks like you have configured the Max Session Time to be 5 minutes, which aligns with the logs. You can extend this time to a longer duration.
But why the random list of groups? Is this presenting a random list of groups to a player - so they can decide which one to try to join or something?