Travian Task Queue

By Nevam Last update Jul 28, 2009 — Installed 417,775 times.

future option

in
Subscribe to future option 2 posts, 2 voices



ashman22 User
FirefoxWindows

sorry I'm not good at programming.
but I would like to know which is the piece of code for comparing the active programmed hours with the current time. and if two hours are the same pass on the order of construction.

I would like to see this to make me an idea of the structure
then I might suggest some idea

thanks in advance, and good day

 
Pimp Trizkit Scriptwright
FirefoxWindows

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:

var oDate = new Date();
var aThisTask = (go get the time of the first scheduled task)
if (aThisTask <= oDate.getTime()/1000) {
(Do the task)
}

Pimp

Cross
Presentational HTML allowed.
Use <code> for inline code and <pre> for code blocks. Use &lt; and &gt; for literal < and >.
We help break paragraphs and link your links.
or cancel