future option
![]() ![]() |
sorry I'm not good at programming.
I would like to see this to make me an idea of the structure
thanks in advance, and good day |
![]() ![]() |
The future time to schedule is calculated in seconds and stored in a variable. Then, its recalled and compared to the current time (in seconds). If the current time is equal to or greater than the time stored, then enough time has passed and it goes to trigger the task. var aTasks = data.split("|");
var bTaskDeleted = false;
for(var i = 0; i < aTasks.length; i++) {
var aThisTask = aTasks[i].split(",");
// The stored time (Unix GMT time) should be compared against the GMT time, not local!
if(aThisTask[1] <= oDate.getTime()/1000) {
_log(2, "Triggering task: " + aTasks[i]);
triggerTask(aThisTask);
aTasks.splice(i, 1); //delete this task
bTaskDeleted = true;
} else if( (aThisTask[0] < 2) && (aThisTask[1] <= ((oDate.getTime()/1000) + iPreloadTime)) ) { //prefetch the code if the task is to be triggered in less than iPreloadTime
_log(2, "Some building/upgrading task is set, but it is not the time yet. It is time to preload the code though.");
getCode(aThisTask[2], aThisTask[4]);
} else {
_log(2, "Some task is set, but it is not the time yet.");
//refresh the session if needed
var sLastRefreshed = getOption('LAST_REFRESH', 0, "integer");
var iRandomMultiplier = (Math.random() < 0.5) ? 1 : -1;
var iRandomMilliSeconds = iRandomMultiplier * 60000 * Math.round(10 * Math.random()); //for randomizing the refresh times (the scatter will be +/- 10 minutes)
if(sLastRefreshed != '' && (iSessionRefreshRate > 0) && (sLastRefreshed + (iSessionRefreshRate * 60000) + iRandomMilliSeconds ) < oDate.getTime() ) {
_log(2, "Refreshing the session...");
get("dorf1.php", null, null)
setOption('LAST_REFRESH', oDate.getTime() );
}
}
}
But basically, if you are using local time. Its doing this:
Pimp |

