TravianZ instant troops training

Results 1 to 1 of 1
  1. #1
    Enthusiast jakbut is offline
    MemberRank
    Apr 2012 Join Date
    30Posts

    TravianZ instant troops training

    hello, all, maybe anyone knows how to make troops to train instantly all amount?
    I searched on forum but found only script which makes it for gold, but i need to make it automaticaly, when player set amount troops to train they builds instant i found that:
    Code:
    function trainUnit($vid, $unit, $amt, $pop, $each, $time, $mode) {
    		global $village, $building, $session, $technology;
    
    		if(!$mode) {
    			$barracks = array(1,2,3,11,12,13,14,21,22,31,32,33,34,35,36,37,38,39,40,41,42,43,44);
    			// fix by brainiac - THANK YOU
    			$greatbarracks = array(61,62,63,71,72,73,74,81,82,91,92,93,94,95,96,97,98,99,100,101,102,103,104);
    			$stables = array(4,5,6,15,16,23,24,25,26,45,46);
    			$greatstables = array(64,65,66,75,76,83,84,85,86,105,106);
    			$workshop = array(7,8,17,18,27,28,47,48);
    			$greatworkshop = array(67,68,77,78,87,88,107,108);
    			$residence = array(9,10,19,20,29,30,49,50);
    			$trapper = array(99);
    
    			if(in_array($unit, $barracks)) {
    				$queued = $technology->getTrainingList(1);
    			} elseif(in_array($unit, $stables)) {
    				$queued = $technology->getTrainingList(2);
    			} elseif(in_array($unit, $workshop)) {
    				$queued = $technology->getTrainingList(3);
    			} elseif(in_array($unit, $residence)) {
    				$queued = $technology->getTrainingList(4);
    			} elseif(in_array($unit, $greatstables)) {
    				$queued = $technology->getTrainingList(6);
    			} elseif(in_array($unit, $greatbarracks)) {
    				$queued = $technology->getTrainingList(5);
    			} elseif(in_array($unit, $greatworkshop)) {
    				$queued = $technology->getTrainingList(7);
    			} elseif(in_array($unit, $trapper)) {
    				$queued = $technology->getTrainingList(8);
    			}
    			$now = time();
    
    	$uid = $this->getVillageField($vid, "owner");
    	$artefact = count($this->getOwnUniqueArtefactInfo2($uid,5,3,0));
    	$artefact1 = count($this->getOwnUniqueArtefactInfo2($vid,5,1,1));
    	$artefact2 = count($this->getOwnUniqueArtefactInfo2($uid,5,2,0));
    	if($artefact > 0){
    	$time = $now+round(($time-$now)/2);
    	$each /= 2;
    	$each = round($each);
    	}else if($artefact1 > 0){
    	$time = $now+round(($time-$now)/2);
    	$each /= 2;
    	$each = round($each);
    	}else if($artefact2 > 0){
    	$time = $now+round(($time-$now)/4*3);
    	$each /= 4;
    	$each = round($each);
    	$each *= 3;
    	$each = round($each);
    	}
    	$foolartefact = $this->getFoolArtefactInfo(5,$vid,$uid);
    	if(count($foolartefact) > 0){
    	foreach($foolartefact as $arte){
    	if($arte['bad_effect'] == 1){
    	$each *= $arte['effect2'];
    	}else{
    	$each /= $arte['effect2'];
    	$each = round($each);
    	}
    	}
    	}
    	if($each == 0){ $each = 1; }
    	$time2 = $now + $each;
    	if(count($queued) > 0) {
    	$time += $queued[count($queued) - 1]['timestamp'] - $now;
    	$time2 += $queued[count($queued) - 1]['timestamp'] - $now;
    	}
    	// TROOPS MAKE SUM IN BARAKS , ETC
    	//if($queued[count($queued) - 1]['unit'] == $unit){
    	//$time = $amt*$queued[count($queued) - 1]['eachtime'];
    	//$q = "UPDATE " . TB_PREFIX . "training SET amt = amt + $amt, timestamp = timestamp + $time WHERE id = ".$queued[count($queued) - 1]['id']."";
    	//}else{
    			$q = "INSERT INTO " . TB_PREFIX . "training values (0,$vid,$unit,$amt,$pop,$time,$each,$time2)";
    	//}
    		} else {
    			$q = "DELETE FROM " . TB_PREFIX . "training where id = $vid";
    		}
    		return mysql_query($q, $this->connection);
    	}
    
    	function updateTraining($id, $trained, $each) {
    	
    		$q = "UPDATE " . TB_PREFIX . "training set amt = amt - $trained, timestamp2 = timestamp2 + $each where id = $id";
    		
    		return mysql_query($q, $this->connection);
    	}
    
    	function modifyUnit($vref, $array_unit, $array_amt, $array_mode){
    		$i = -1;
    		$units='';
    		$number = count($array_unit);
    		foreach($array_unit as $unit){
    			if($unit == 230){$unit = 30;}
    			if($unit == 231){$unit = 31;}
    			if($unit == 120){$unit = 20;}
    			if($unit == 121){$unit = 21;}
    			if($unit =="hero"){$unit = 'hero';}
    			else{$unit = 'u' . $unit;}
    
    			++$i;
    			$units .= $unit.' = '.$unit.' '.(($array_mode[$i] == 1)? '+':'-').'  '.$array_amt[$i].(($number > $i+1) ? ', ' : '');
    		}
    
    		$q = "UPDATE ".TB_PREFIX."units set $units WHERE vref = $vref";
    		return mysql_query($q, $this->connection);
    	}
    i think i need do something here.




Advertisement