• Unfortunately, we have experienced significant hard drive damage that requires urgent maintenance and rebuilding. The forum will be a state of read only until we install our new drives and rebuild all the configurations needed. Please follow our Facebook page for updates, we will be back up shortly! (The forum could go offline at any given time due to the nature of the failed drives whilst awaiting the upgrades.) When you see an Incapsula error, you know we are in the process of migration.

Travianz forces killed if wheat becomes negative NEW

Status
Not open for further replies.
Initiate Mage
Joined
Jun 8, 2012
Messages
1
Reaction score
0
Let me salute you gave way Arabs
Peace be upon you and God's mercy and blessings

flie Village.php :

and new flie Units_-.php


Method of installation Place the files in this folder

PHP:
GameEngine

or code
Village.php
PHP:
<?php
##################################################### 
#                                       Travian Clone                                           # 
# --------------------------------------------------------------------------------# 
#                                              By : Sultan                                        # 
#                                 fix : Village.php                                             # 
#                 message : fix Travian Clone 100% LODING                     # 
#-------------------------------------------------------------------------------# 
################################################### 


include("Session.php");
include("Building.php");
include("Market.php");
include("Technology.php");

class Village {

	public $type;
	public $coor = array();
	public $awood,$aclay,$airon,$acrop,$pop,$maxstore,$maxcrop;
	public $wid,$vname,$capital,$natar,$master;
	public $resarray = array();
	public $unitarray,$techarray,$unitall,$researching,$abarray = array();
	private $infoarray = array();
	private $production = array();
	private $oasisowned,$ocounter = array();

	function Village() {
		global $session;
		if(isset($_SESSION['wid'])) {
			$this->wid = $_SESSION['wid'];
		}
		else {
			$this->wid = $session->villages[0];
		}
		$this->LoadTown();
		$this->calculateProduction();
		$this->processProduction();
		$this->ActionControl();
	}

	public function getProd($type) {
		return $this->production[$type];
	}

	public function getAllUnits($vid) {
		global $database,$technology;
		return $technology->getUnits($database->getUnit($vid),$database->getEnforceVillage($vid,0));
	}

	private function LoadTown() {
		global $database,$session,$logging,$technology;
		$this->infoarray = $database->getVillage($this->wid);
		if($this->infoarray['owner'] != $session->uid && !$session->isAdmin) {
			unset($_SESSION['wid']);
			$logging->addIllegal($session->uid,$this->wid,1);
			$this->wid = $session->villages[0];
			$this->infoarray = $database->getVillage($this->wid);
		}
		$this->resarray = $database->getResourceLevel($this->wid);
		$this->coor = $database->getCoor($this->wid);
		$this->type = $database->getVillageType($this->wid);
		$this->oasisowned = $database->getOasis($this->wid);
		$this->ocounter = $this->sortOasis();
		$this->unitarray = $database->getUnit($this->wid);
		$this->enforcetome = $database->getEnforceVillage($this->wid,0);
		$this->enforcetoyou = $database->getEnforceVillage($this->wid,1);
		$this->unitall =  $technology->getAllUnits($this->wid);
		$this->techarray = $database->getTech($this->wid);
		$this->abarray = $database->getABTech($this->wid);
		$this->researching = $database->getResearching($this->wid);

		$this->capital = $this->infoarray['capital'];
		$this->natar = $this->infoarray['natar'];
		$this->currentcel = $this->infoarray['celebration'];
		$this->wid = $this->infoarray['wref'];
		$this->vname = $this->infoarray['name'];
		$this->awood = $this->infoarray['wood'];
		$this->aclay = $this->infoarray['clay'];
		$this->airon = $this->infoarray['iron'];
		$this->acrop = $this->infoarray['crop'];
		$this->pop = $this->infoarray['pop'];
		$this->maxstore = $this->infoarray['maxstore'];
		$this->maxcrop = $this->infoarray['maxcrop'];
		$this->allcrop = $this->getCropProd();
		$this->loyalty = $this->infoarray['loyalty'];
		$this->master = count($database->getMasterJobs($this->wid));
		//de gs in town, zetten op max pakhuisinhoud
		if($this->awood>$this->maxstore){ $this->awood=$this->maxstore; $database->updateResource($this->wid,'wood',$this->maxstore); }
		if($this->aclay>$this->maxstore){ $this->aclay=$this->maxstore; $database->updateResource($this->wid,'clay',$this->maxstore); }
		if($this->airon>$this->maxstore){ $this->airon=$this->maxstore; $database->updateResource($this->wid,'iron',$this->maxstore); }
		if($this->acrop>$this->maxcrop){ $this->acrop=$this->maxcrop; $database->updateResource($this->wid,'crop',$this->maxcrop); }

	}

	private function calculateProduction() {
		global $technology,$database,$session;
		$normalA = $database->getOwnArtefactInfoByType($_SESSION['wid'],4);
		$largeA = $database->getOwnUniqueArtefactInfo($session->uid,4,2);
		$uniqueA = $database->getOwnUniqueArtefactInfo($session->uid,4,3);
		$upkeep = $technology->getUpkeep($this->unitall,0,$this->wid);
		$this->production['wood'] = $this->getWoodProd();
		$this->production['clay'] = $this->getClayProd();
		$this->production['iron'] = $this->getIronProd();
		if ($uniqueA['size']==3 && $uniqueA['owner']==$session->uid){
		$this->production['crop'] = $this->getCropProd()-$this->pop-(($upkeep)-round($upkeep*0.50));

		}else if ($normalA['type']==4 && $normalA['size']==1 && $normalA['owner']==$session->uid){
		$this->production['crop'] = $this->getCropProd()-$this->pop-(($upkeep)-round($upkeep*0.25));

		}else if ($largeA['size']==2 && $largeA['owner']==$session->uid){
		 $this->production['crop'] = $this->getCropProd()-$this->pop-(($upkeep)-round($upkeep*0.25));

		}else{
		$this->production['crop'] = $this->getCropProd()-$this->pop-$upkeep;
	}
	}


	private function processProduction() {
		global $database;
		$timepast = time() - $this->infoarray['lastupdate'];
		$nwood = ($this->production['wood'] / 3600) * $timepast;
		$nclay = ($this->production['clay'] / 3600) * $timepast;
		$niron = ($this->production['iron'] / 3600) * $timepast;
		$ncrop = ($this->production['crop'] / 3600) * $timepast;

		$database->modifyResource($this->wid,$nwood,$nclay,$niron,$ncrop,1);
		$database->updateVillage($this->wid);
		$this->LoadTown();
	}

	private function getWoodProd() {
		global $bid1,$bid5,$session;
		$basewood = $sawmill = 0;
		$woodholder = array();
		for($i=1;$i<=38;$i++) {
			if($this->resarray['f'.$i.'t'] == 1) {
				array_push($woodholder,'f'.$i);
			}
			if($this->resarray['f'.$i.'t'] == 5) {
				$sawmill = $this->resarray['f'.$i];
			}
		}
		for($i=0;$i<=count($woodholder)-1;$i++) { $basewood+= $bid1[$this->resarray[$woodholder[$i]]]['prod']; }
		$wood = $basewood + $basewood * 0.25 * $this->ocounter[0];
		if($sawmill >= 1) {
			$wood += $basewood / 100 * $bid5[$sawmill]['attri'];
		}
		if($session->bonus1 == 1) {
			$wood *= 1.25;
		}
		$wood *= SPEED;
		return round($wood);
	}

	private function getClayProd() {
		global $bid2,$bid6,$session;
		$baseclay = $clay = $brick = 0;
		$clayholder = array();
		for($i=1;$i<=38;$i++) {
			if($this->resarray['f'.$i.'t'] == 2) {
				array_push($clayholder,'f'.$i);
			}
			if($this->resarray['f'.$i.'t'] == 6) {
				$brick = $this->resarray['f'.$i];
			}
		}
		for($i=0;$i<=count($clayholder)-1;$i++) { $baseclay+= $bid2[$this->resarray[$clayholder[$i]]]['prod']; }
		$clay = $baseclay + $baseclay * 0.25 * $this->ocounter[1];
		if($brick >= 1) {
			$clay += $baseclay / 100 * $bid6[$brick]['attri'];
		}
		if($session->bonus2 == 1) {
			$clay *= 1.25;
		}
		$clay *= SPEED;
		return round($clay);
	}

	private function getIronProd() {
		global $bid3,$bid7,$session;
		$baseiron = $foundry = 0;
		$ironholder = array();
		for($i=1;$i<=38;$i++) {
			if($this->resarray['f'.$i.'t'] == 3) {
				array_push($ironholder,'f'.$i);
			}
			if($this->resarray['f'.$i.'t'] == 7) {
				$foundry = $this->resarray['f'.$i];
			}
		}
		for($i=0;$i<=count($ironholder)-1;$i++) { $baseiron+= $bid3[$this->resarray[$ironholder[$i]]]['prod']; }
		$iron = $baseiron + $baseiron * 0.25 * $this->ocounter[2];
		if($foundry >= 1) {
			$iron += $baseiron / 100 * $bid7[$foundry]['attri'];
		}
		if($session->bonus3 == 1) {
			$iron *= 1.25;
		}
		$iron *= SPEED;
		return round($iron);
	}

	private function getCropProd() {
		global $bid4,$bid8,$bid9,$session;
		$basecrop = $grainmill = $bakery = 0;
		$cropholder = array();
		for($i=1;$i<=38;$i++) {
			if($this->resarray['f'.$i.'t'] == 4) {
				array_push($cropholder,'f'.$i);
			}
			if($this->resarray['f'.$i.'t'] == 8) {
				$grainmill = $this->resarray['f'.$i];
			}
			if($this->resarray['f'.$i.'t'] == 9) {
				$bakery = $this->resarray['f'.$i];
			}
		}
		for($i=0;$i<=count($cropholder)-1;$i++) { $basecrop+= $bid4[$this->resarray[$cropholder[$i]]]['prod']; }
		$crop = $basecrop + $basecrop * 0.25 * $this->ocounter[3];
		if($grainmill >= 1 || $bakery >= 1) {
			$crop += $basecrop /100 * ($bid8[$grainmill]['attri'] + $bid9[$bakery]['attri']);
		}
		if($session->bonus4 == 1) {
			$crop *= 1.25;
		}
		$crop *= SPEED;
		return round($crop);
	}

	private function sortOasis() {
		$crop = $clay = $wood = $iron = 0;
		if (!empty($this->oasisowned)) {
			foreach ($this->oasisowned as $oasis) {
			switch($oasis['type']) {
					case 1:
					case 2:
					$wood += 1;
					break;
					case 3:
					$wood += 1;
					$crop += 1;
					break;
					case 4:
					case 5:
					$clay += 1;
					break;
					case 6:
					$clay += 1;
					$crop += 1;
					break;
					case 7:
					case 8:
					$iron += 1;
					break;
					case 9:
					$iron += 1;
					$crop += 1;
					break;
					case 10:
					case 11:
					$crop += 1;
					break;
					case 12:
					$crop += 2;
					break;
				}
			}
		}
		return array($wood,$clay,$iron,$crop);
	}

	private function ActionControl() {
		global $session;
		if(SERVER_WEB_ROOT) {
			$page = $_SERVER['SCRIPT_NAME'];
		}
		else {
			$explode = explode("/",$_SERVER['SCRIPT_NAME']);
			$i = count($explode)-1;
			$page = $explode[$i];
		}
		if($page == "build.php" && $session->uid != $this->infoarray['owner']) {
			unset($_SESSION['wid']);
			header("Location: dorf1.php");
		}
	}
};
$village = new Village;
$building = new Building;
include('Units_-.php');
?>
Units_-.php
PHP:
<?php
#####################################################
#                                       Travian Clone                                           #
# --------------------------------------------------------------------------------#
#                                              By : Sultan                                        #
#                                 fix : Units_-.php                                             #
#                 message : fix Travian Clone 100% LODING                     #
#-------------------------------------------------------------------------------#
###################################################
$is = $village->wid;
$result = mysql_query("SELECT * FROM units where vref=$is");
$units = mysql_fetch_array($result);
if($village->getProd("crop") <= '-1') {
            if ($units['u1'] > 0)
           {
	mysql_query("UPDATE `units` set `u1` = `u1`- 1 where vref='".$village->wid."'"); 
            }
            if ($units['u2'] > 0)
           {
	mysql_query("UPDATE `units` set `u2` = `u2`- 1 where vref='".$village->wid."'"); 
            }
            if ($units['u3'] > 0)
           {
	mysql_query("UPDATE `units` set `u3` = `u3`- 1 where vref='".$village->wid."'"); 
            }
            if ($units['u4'] > 0)
           {
	mysql_query("UPDATE `units` set `u4` = `u4`- 1 where vref='".$village->wid."'"); 
            }
            if ($units['u5'] > 0)
           {
	mysql_query("UPDATE `units` set `u5` = `u5`- 1 where vref='".$village->wid."'"); 
            }
            if ($units['u6'] > 0)
           {
	mysql_query("UPDATE `units` set `u6` = `u6`- 1 where vref='".$village->wid."'"); 
            }
            if ($units['u7'] > 0)
           {
	mysql_query("UPDATE `units` set `u7` = `u7`- 1 where vref='".$village->wid."'"); 
            }
            if ($units['u8'] > 0)
           {
	mysql_query("UPDATE `units` set `u8` = `u8`- 1 where vref='".$village->wid."'"); 
            }
            if ($units['u9'] > 0)
           {
	mysql_query("UPDATE `units` set `u9` = `u9`- 1 where vref='".$village->wid."'"); 
            }
            if ($units['u10'] > 0)
           {
	mysql_query("UPDATE `units` set `u10` = `u10`- 1 where vref='".$village->wid."'"); 
            }
            if ($units['u11'] > 0)
           {
	mysql_query("UPDATE `units` set `u11` = `u11`- 1 where vref='".$village->wid."'"); 
            }
            if ($units['u12'] > 0)
           {
	mysql_query("UPDATE `units` set `u12` = `u12`- 1 where vref='".$village->wid."'"); 
            }
            if ($units['u13'] > 0)
           {
	mysql_query("UPDATE `units` set `u13` = `u13`- 1 where vref='".$village->wid."'"); 
            }
            if ($units['u14'] > 0)
           {
	mysql_query("UPDATE `units` set `u14` = `u14`- 1 where vref='".$village->wid."'"); 
            }
            if ($units['u15'] > 0)
           {
	mysql_query("UPDATE `units` set `u15` = `u15`- 1 where vref='".$village->wid."'"); 
            }
            if ($units['u16'] > 0)
           {
	mysql_query("UPDATE `units` set `u16` = `u16`- 1 where vref='".$village->wid."'"); 
            }
            if ($units['u17'] > 0)
           {
	mysql_query("UPDATE `units` set `u17` = `u17`- 1 where vref='".$village->wid."'"); 
            }
            if ($units['u18'] > 0)
           {
	mysql_query("UPDATE `units` set `u18` = `u18`- 1 where vref='".$village->wid."'"); 
            }
            if ($units['u19'] > 0)
           {
	mysql_query("UPDATE `units` set `u19` = `u19`- 1 where vref='".$village->wid."'"); 
            }
            if ($units['u20'] > 0)
           {
	mysql_query("UPDATE `units` set `u20` = `u20`- 1 where vref='".$village->wid."'"); 
            }
            if ($units['u21'] > 0)
           {
	mysql_query("UPDATE `units` set `u21` = `u21`- 1 where vref='".$village->wid."'"); 
            }
            if ($units['u22'] > 0)
           {
	mysql_query("UPDATE `units` set `u22` = `u22`- 1 where vref='".$village->wid."'"); 
            }
            if ($units['u23'] > 0)
           {
	mysql_query("UPDATE `units` set `u23` = `u23`- 1 where vref='".$village->wid."'"); 
            }
            if ($units['u24'] > 0)
           {
	mysql_query("UPDATE `units` set `u24` = `u24`- 1 where vref='".$village->wid."'"); 
            }
            if ($units['u25'] > 0)
           {
	mysql_query("UPDATE `units` set `u25` = `u25`- 1 where vref='".$village->wid."'"); 
            }
            if ($units['u26'] > 0)
           {
	mysql_query("UPDATE `units` set `u26` = `u26`- 1 where vref='".$village->wid."'"); 
            }
            if ($units['u27'] > 0)
           {
	mysql_query("UPDATE `units` set `u27` = `u27`- 1 where vref='".$village->wid."'"); 
            }
            if ($units['u28'] > 0)
           {
	mysql_query("UPDATE `units` set `u28` = `u28`- 1 where vref='".$village->wid."'"); 
            }
            if ($units['u29'] > 0)
           {
	mysql_query("UPDATE `units` set `u29` = `u29`- 1 where vref='".$village->wid."'"); 
            }
            if ($units['u30'] > 0)
           {
	mysql_query("UPDATE `units` set `u30` = `u30`- 1 where vref='".$village->wid."'"); 
            }
            if ($units['u31'] > 0)
           {
	mysql_query("UPDATE `units` set `u31` = `u31`- 1 where vref='".$village->wid."'"); 
            }
            if ($units['u32'] > 0)
           {
	mysql_query("UPDATE `units` set `u32` = `u32`- 1 where vref='".$village->wid."'"); 
            }
            if ($units['u33'] > 0)
           {
	mysql_query("UPDATE `units` set `u33` = `u33`- 1 where vref='".$village->wid."'"); 
            }
            if ($units['u34'] > 0)
           {
	mysql_query("UPDATE `units` set `u34` = `u34`- 1 where vref='".$village->wid."'"); 
            }
            if ($units['u35'] > 0)
           {
	mysql_query("UPDATE `units` set `u35` = `u35`- 1 where vref='".$village->wid."'"); 
            }
            if ($units['u36'] > 0)
           {
	mysql_query("UPDATE `units` set `u36` = `u36`- 1 where vref='".$village->wid."'"); 
            }
            if ($units['u37'] > 0)
           {
	mysql_query("UPDATE `units` set `u37` = `u37`- 1 where vref='".$village->wid."'"); 
            }
            if ($units['u38'] > 0)
           {
	mysql_query("UPDATE `units` set `u38` = `u38`- 1 where vref='".$village->wid."'"); 
            }
            if ($units['u39'] > 0)
           {
	mysql_query("UPDATE `units` set `u39` = `u39`- 1 where vref='".$village->wid."'"); 
            }
            if ($units['u40'] > 0)
           {
	mysql_query("UPDATE `units` set `u40` = `u40`- 1 where vref='".$village->wid."'"); 
            }
            if ($units['u41'] > 0)
           {
	mysql_query("UPDATE `units` set `u41` = `u41`- 1 where vref='".$village->wid."'"); 
            }
            if ($units['u42'] > 0)
           {
	mysql_query("UPDATE `units` set `u42` = `u42`- 1 where vref='".$village->wid."'"); 
            }
            if ($units['u43'] > 0)
           {
	mysql_query("UPDATE `units` set `u43` = `u43`- 1 where vref='".$village->wid."'"); 
            }
            if ($units['u44'] > 0)
           {
	mysql_query("UPDATE `units` set `u44` = `u44`- 1 where vref='".$village->wid."'"); 
            }
            if ($units['u45'] > 0)
           {
	mysql_query("UPDATE `units` set `u45` = `u45`- 1 where vref='".$village->wid."'"); 
            }
            if ($units['u46'] > 0)
           {
	mysql_query("UPDATE `units` set `u46` = `u46`- 1 where vref='".$village->wid."'"); 
            }
            if ($units['u47'] > 0)
           {
	mysql_query("UPDATE `units` set `u47` = `u47`- 1 where vref='".$village->wid."'"); 
            }
            if ($units['u48'] > 0)
           {
	mysql_query("UPDATE `units` set `u48` = `u48`- 1 where vref='".$village->wid."'"); 
            }
            if ($units['u49'] > 0)
           {
	mysql_query("UPDATE `units` set `u49` = `u49`- 1 where vref='".$village->wid."'"); 
            }
            if ($units['u50'] > 0)
           {
	mysql_query("UPDATE `units` set `u50` = `u50`- 1 where vref='".$village->wid."'"); 
            }
}
?>
Good Gays Bay :eek:tt::blush:
 
Newbie Spellweaver
Joined
Dec 16, 2012
Messages
25
Reaction score
0
I will try it. And how bad this script slows whole server? at localhost , some host?
 
Newbie Spellweaver
Joined
Dec 16, 2012
Messages
25
Reaction score
0
Ok so i tried this scripts with Crop: -7800009 per hour and it does not work?
 
Junior Spellweaver
Joined
Apr 8, 2012
Messages
102
Reaction score
9
Ok so i tried this scripts with Crop: -7800009 per hour and it does not work?

Because theres even no database connection files.

For example:
PHP:
		$link = mysql_connect ($DB["host"], $DB["user"], $DB["password"]);
		mysql_select_db ($DB["database"], $link);
		$this->link = $link;

This script not only makes TravianZ slower even more, but is an incomplete script jQuery aswell.
 
Divine Celestial
Joined
Feb 25, 2013
Messages
808
Reaction score
343
Because theres even no database connection files.

For example:
PHP:
        $link = mysql_connect ($DB["host"], $DB["user"], $DB["password"]);
        mysql_select_db ($DB["database"], $link);
        $this->link = $link;

This script not only makes TravianZ slower even more, but is an incomplete script jQuery aswell.
no, error is not there, error is here:
Code:
[COLOR=#007700]if([/COLOR][COLOR=#0000BB]$village[/COLOR][COLOR=#007700]->[/COLOR][COLOR=#0000BB]getProd[/COLOR][COLOR=#007700]([/COLOR][COLOR=#DD0000]"crop"[/COLOR][COLOR=#007700]) <= [/COLOR][COLOR=#DD0000]'-1'[/COLOR][COLOR=#007700]) {
[/COLOR]

it should be like:
Code:
if($village->getProd("crop") < 0)
{
 
Newbie Spellweaver
Joined
Dec 16, 2012
Messages
25
Reaction score
0
Ok guys it works but now my build.php is blank :D Fixed it
 
Last edited:
Skilled Illusionist
Joined
Mar 9, 2011
Messages
391
Reaction score
120
Good code , ".TB_PREFIX." missing in front of mysql. Works perfectly now.

PHP:
 <?php
###################################################################################
#                                       Travian Clone                             #
#---------------------------------------------------------------------------------#
#                                              By : Sultan                        #
#                                 fix : Units_-.php                               #
#                 message : fix Travian Clone 100% LODING                         #
#---------------------------------------------------------------------------------#
###################################################################################
$is = $village->wid;
$result = mysql_query("SELECT * FROM ".TB_PREFIX."units WHERE vref=$is");
$units = mysql_fetch_array($result);
if($village->getProd("crop") <= '-1') {
            if ($units['u1'] > 0)
           {
    mysql_query("UPDATE ".TB_PREFIX."units set `u1` = `u1`- 1 where vref='".$village->wid."'"); 
            }
            if ($units['u2'] > 0)
           {
    mysql_query("UPDATE ".TB_PREFIX."units set `u2` = `u2`- 1 where vref='".$village->wid."'"); 
            }
            if ($units['u3'] > 0)
           {
    mysql_query("UPDATE ".TB_PREFIX."units set `u3` = `u3`- 1 where vref='".$village->wid."'"); 
            }
            if ($units['u4'] > 0)
           {
    mysql_query("UPDATE ".TB_PREFIX."units set `u4` = `u4`- 1 where vref='".$village->wid."'"); 
            }
            if ($units['u5'] > 0)
           {
    mysql_query("UPDATE ".TB_PREFIX."units set `u5` = `u5`- 1 where vref='".$village->wid."'"); 
            }
            if ($units['u6'] > 0)
           {
    mysql_query("UPDATE ".TB_PREFIX."units set `u6` = `u6`- 1 where vref='".$village->wid."'"); 
            }
            if ($units['u7'] > 0)
           {
    mysql_query("UPDATE ".TB_PREFIX."units set `u7` = `u7`- 1 where vref='".$village->wid."'"); 
            }
            if ($units['u8'] > 0)
           {
    mysql_query("UPDATE ".TB_PREFIX."units set `u8` = `u8`- 1 where vref='".$village->wid."'"); 
            }
            if ($units['u9'] > 0)
           {
    mysql_query("UPDATE ".TB_PREFIX."units set `u9` = `u9`- 1 where vref='".$village->wid."'"); 
            }
            if ($units['u10'] > 0)
           {
    mysql_query("UPDATE ".TB_PREFIX."units set `u10` = `u10`- 1 where vref='".$village->wid."'"); 
            }
            if ($units['u11'] > 0)
           {
    mysql_query("UPDATE ".TB_PREFIX."units set `u11` = `u11`- 1 where vref='".$village->wid."'"); 
            }
            if ($units['u12'] > 0)
           {
    mysql_query("UPDATE ".TB_PREFIX."units set `u12` = `u12`- 1 where vref='".$village->wid."'"); 
            }
            if ($units['u13'] > 0)
           {
    mysql_query("UPDATE ".TB_PREFIX."units set `u13` = `u13`- 1 where vref='".$village->wid."'"); 
            }
            if ($units['u14'] > 0)
           {
    mysql_query("UPDATE ".TB_PREFIX."units set `u14` = `u14`- 1 where vref='".$village->wid."'"); 
            }
            if ($units['u15'] > 0)
           {
    mysql_query("UPDATE ".TB_PREFIX."units set `u15` = `u15`- 1 where vref='".$village->wid."'"); 
            }
            if ($units['u16'] > 0)
           {
    mysql_query("UPDATE ".TB_PREFIX."units set `u16` = `u16`- 1 where vref='".$village->wid."'"); 
            }
            if ($units['u17'] > 0)
           {
    mysql_query("UPDATE ".TB_PREFIX."units set `u17` = `u17`- 1 where vref='".$village->wid."'"); 
            }
            if ($units['u18'] > 0)
           {
    mysql_query("UPDATE ".TB_PREFIX."units set `u18` = `u18`- 1 where vref='".$village->wid."'"); 
            }
            if ($units['u19'] > 0)
           {
    mysql_query("UPDATE ".TB_PREFIX."units set `u19` = `u19`- 1 where vref='".$village->wid."'"); 
            }
            if ($units['u20'] > 0)
           {
    mysql_query("UPDATE ".TB_PREFIX."units set `u20` = `u20`- 1 where vref='".$village->wid."'"); 
            }
            if ($units['u21'] > 0)
           {
    mysql_query("UPDATE ".TB_PREFIX."units set `u21` = `u21`- 1 where vref='".$village->wid."'"); 
            }
            if ($units['u22'] > 0)
           {
    mysql_query("UPDATE ".TB_PREFIX."units set `u22` = `u22`- 1 where vref='".$village->wid."'"); 
            }
            if ($units['u23'] > 0)
           {
    mysql_query("UPDATE ".TB_PREFIX."units set `u23` = `u23`- 1 where vref='".$village->wid."'"); 
            }
            if ($units['u24'] > 0)
           {
    mysql_query("UPDATE ".TB_PREFIX."units set `u24` = `u24`- 1 where vref='".$village->wid."'"); 
            }
            if ($units['u25'] > 0)
           {
    mysql_query("UPDATE ".TB_PREFIX."units set `u25` = `u25`- 1 where vref='".$village->wid."'"); 
            }
            if ($units['u26'] > 0)
           {
    mysql_query("UPDATE ".TB_PREFIX."units set `u26` = `u26`- 1 where vref='".$village->wid."'"); 
            }
            if ($units['u27'] > 0)
           {
    mysql_query("UPDATE ".TB_PREFIX."units set `u27` = `u27`- 1 where vref='".$village->wid."'"); 
            }
            if ($units['u28'] > 0)
           {
    mysql_query("UPDATE ".TB_PREFIX."units set `u28` = `u28`- 1 where vref='".$village->wid."'"); 
            }
            if ($units['u29'] > 0)
           {
    mysql_query("UPDATE ".TB_PREFIX."units set `u29` = `u29`- 1 where vref='".$village->wid."'"); 
            }
            if ($units['u30'] > 0)
           {
    mysql_query("UPDATE ".TB_PREFIX."units set `u30` = `u30`- 1 where vref='".$village->wid."'"); 
            }
            if ($units['u31'] > 0)
           {
    mysql_query("UPDATE ".TB_PREFIX."units set `u31` = `u31`- 1 where vref='".$village->wid."'"); 
            }
            if ($units['u32'] > 0)
           {
    mysql_query("UPDATE ".TB_PREFIX."units set `u32` = `u32`- 1 where vref='".$village->wid."'"); 
            }
            if ($units['u33'] > 0)
           {
    mysql_query("UPDATE ".TB_PREFIX."units set `u33` = `u33`- 1 where vref='".$village->wid."'"); 
            }
            if ($units['u34'] > 0)
           {
    mysql_query("UPDATE ".TB_PREFIX."units set `u34` = `u34`- 1 where vref='".$village->wid."'"); 
            }
            if ($units['u35'] > 0)
           {
    mysql_query("UPDATE ".TB_PREFIX."units set `u35` = `u35`- 1 where vref='".$village->wid."'"); 
            }
            if ($units['u36'] > 0)
           {
    mysql_query("UPDATE ".TB_PREFIX."units set `u36` = `u36`- 1 where vref='".$village->wid."'"); 
            }
            if ($units['u37'] > 0)
           {
    mysql_query("UPDATE ".TB_PREFIX."units set `u37` = `u37`- 1 where vref='".$village->wid."'"); 
            }
            if ($units['u38'] > 0)
           {
    mysql_query("UPDATE ".TB_PREFIX."units set `u38` = `u38`- 1 where vref='".$village->wid."'"); 
            }
            if ($units['u39'] > 0)
           {
    mysql_query("UPDATE ".TB_PREFIX."units set `u39` = `u39`- 1 where vref='".$village->wid."'"); 
            }
            if ($units['u40'] > 0)
           {
    mysql_query("UPDATE ".TB_PREFIX."units set `u40` = `u40`- 1 where vref='".$village->wid."'"); 
            }
            if ($units['u41'] > 0)
           {
    mysql_query("UPDATE ".TB_PREFIX."units set `u41` = `u41`- 1 where vref='".$village->wid."'"); 
            }
            if ($units['u42'] > 0)
           {
    mysql_query("UPDATE ".TB_PREFIX."units set `u42` = `u42`- 1 where vref='".$village->wid."'"); 
            }
            if ($units['u43'] > 0)
           {
    mysql_query("UPDATE ".TB_PREFIX."units set `u43` = `u43`- 1 where vref='".$village->wid."'"); 
            }
            if ($units['u44'] > 0)
           {
    mysql_query("UPDATE ".TB_PREFIX."units set `u44` = `u44`- 1 where vref='".$village->wid."'"); 
            }
            if ($units['u45'] > 0)
           {
    mysql_query("UPDATE ".TB_PREFIX."units set `u45` = `u45`- 1 where vref='".$village->wid."'"); 
            }
            if ($units['u46'] > 0)
           {
    mysql_query("UPDATE ".TB_PREFIX."units set `u46` = `u46`- 1 where vref='".$village->wid."'"); 
            }
            if ($units['u47'] > 0)
           {
    mysql_query("UPDATE ".TB_PREFIX."units set `u47` = `u47`- 1 where vref='".$village->wid."'"); 
            }
            if ($units['u48'] > 0)
           {
    mysql_query("UPDATE ".TB_PREFIX."units set `u48` = `u48`- 1 where vref='".$village->wid."'"); 
            }
            if ($units['u49'] > 0)
           {
    mysql_query("UPDATE ".TB_PREFIX."units set `u49` = `u49`- 1 where vref='".$village->wid."'"); 
            }
            if ($units['u50'] > 0)
           {
    mysql_query("UPDATE ".TB_PREFIX."units set `u50` = `u50`- 1 where vref='".$village->wid."'"); 
            }
}
?>
 
Joined
May 15, 2009
Messages
799
Reaction score
558
This 51 query script annoys me cause every refresh if in negative its 51 queries you want less so here is something i just thrown together to show you how it could be done better you could keep improving it but ill leave that for you guys.
PHP:
 <?php
   /**
   * alot smaller
   * author Advocaite
   * 
   * @var YOLO
   */
$is = $village->wid;
$result = mysql_query("SELECT * FROM ".TB_PREFIX."units WHERE vref=$is");
$units = mysql_fetch_array($result);
$field= "";
if($village->getProd("crop") < 0) { 
for ($i = 1; $i <= 50; $i++) {
    //echo $i;
    if($i ==1){
        $start =" ";
    }else {
        $start = ", ";
    }
    if ($units['u'.$i] > 0)  {
      $field .=$start."`u".$i."` = `u".$i."`-1 ";
    }   
}
 mysql_query("UPDATE ".TB_PREFIX."units set ".$field." where vref='".$village->wid."'");

}
?>
rep and like if you like it or it helped you
 
Junior Spellweaver
Joined
Jan 12, 2012
Messages
154
Reaction score
48
This 51 query script annoys me cause every refresh if in negative its 51 queries you want less so here is something i just thrown together to show you how it could be done better you could keep improving it but ill leave that for you guys.
PHP:
 <?php
   /**
   * alot smaller
   * author Advocaite
   * 
   * @var YOLO
   */
$is = $village->wid;
$result = mysql_query("SELECT * FROM ".TB_PREFIX."units WHERE vref=$is");
$units = mysql_fetch_array($result);
$field= "";
if($village->getProd("crop") < 0) { 
for ($i = 1; $i <= 50; $i++) {
    //echo $i;
    if($i ==1){
        $start =" ";
    }else {
        $start = ", ";
    }
    if ($units['u'.$i] > 0)  {
      $field .=$start."`u".$i."` = `u".$i."`-1 ";
    }   
}
 mysql_query("UPDATE ".TB_PREFIX."units set ".$field." where vref='".$village->wid."'");

}
?>
rep and like if you like it or it helped you

So is this fully working Advo ?

Regards
 
Joined
May 15, 2009
Messages
799
Reaction score
558
yes as far as i know this should work exactly how the first script should work it could be expanded to be more offical but it should work i dont use travianz so im not to sure its been a while since i been anywhere near this source
 
Junior Spellweaver
Joined
Jan 12, 2012
Messages
154
Reaction score
48
yes as far as i know this should work exactly how the first script should work it could be expanded to be more offical but it should work i dont use travianz so im not to sure its been a while since i been anywhere near this source

So i added a code in village.php which will include starve.php.
put your code into root/starve.php and its not working, any misstakes ?
 
Skilled Illusionist
Joined
Mar 9, 2011
Messages
391
Reaction score
120
I allready try to put online on Units_-.php advo code but nothing ...
 
Newbie Spellweaver
Joined
Apr 24, 2012
Messages
6
Reaction score
2
like this
PHP:
$is = $village->wid;
$rcount = count(mysql_query("SELECT * FROM ".TB_PREFIX."enforcement where vref=$is"));
$result = mysql_query("SELECT * FROM ".TB_PREFIX."units where vref=$is");
while($unit = mysql_fetch_assoc($result)){
	if($rcount == 0) {
		if($village->getProd("crop") <= '-1000000000') {
			for ($i = 0; $i <= 30; $i++) {
				if ($unit['u'.$i] > 0) { $minunit = rand(1000,1000000);
					mysql_query("UPDATE ".TB_PREFIX."units set `u".$i."` = `u".$i."`- ".$minunit." where vref='".$village->wid."'"); }
			}
		}
		if($village->getProd("crop") <= '-1000000') {
			for ($i = 0; $i <= 30; $i++) {
				if ($unit['u'.$i] > 0) { $minunit = rand(10,1000);
					mysql_query("UPDATE ".TB_PREFIX."units set `u".$i."` = `u".$i."`- ".$minunit." where vref='".$village->wid."'"); }
			}
		}
		if($village->getProd("crop") <= '-1000') {
			for ($i = 0; $i <= 30; $i++) {
				if ($unit['u'.$i] > 0) { $minunit = rand(1,10);
					mysql_query("UPDATE ".TB_PREFIX."units set `u".$i."` = `u".$i."`- ".$minunit." where vref='".$village->wid."'"); }
			}
		}
	} else {
		if($village->getProd("crop") <= '-1000000000') {
			for ($i = 0; $i <= 30; $i++) {
				if ($unit['u'.$i] > 0) { $minunit = rand(500,500000);
					mysql_query("UPDATE ".TB_PREFIX."enforcement set `u".$i."` = `u".$i."`- ".$minunit." where vref='".$village->wid."'"); 
					mysql_query("UPDATE ".TB_PREFIX."units set `u".$i."` = `u".$i."`- ".$minunit." where vref='".$village->wid."'"); }
			}
		}
		if($village->getProd("crop") <= '-1000000') {
			for ($i = 0; $i <= 30; $i++) {
				if ($unit['u'.$i] > 0) { $minunit = rand(5,500);
					mysql_query("UPDATE ".TB_PREFIX."enforcement set `u".$i."` = `u".$i."`- ".$minunit." where vref='".$village->wid."'"); 
					mysql_query("UPDATE ".TB_PREFIX."units set `u".$i."` = `u".$i."`- ".$minunit." where vref='".$village->wid."'"); }
			}
		}
		if($village->getProd("crop") <= '-1000') {
			for ($i = 0; $i <= 30; $i++) {
				if ($unit['u'.$i] > 0) { $minunit = rand(1,5);
					mysql_query("UPDATE ".TB_PREFIX."enforcement set `u".$i."` = `u".$i."`- ".$minunit." where vref='".$village->wid."'"); 
					mysql_query("UPDATE ".TB_PREFIX."units set `u".$i."` = `u".$i."`- ".$minunit." where vref='".$village->wid."'"); }
			}
		}
	}

	$maxunit = 150000000000;
	for ($i = 0; $i <= 50; $i++) {
		if ($unit['u'.$i] > $maxunit) {
			mysql_query("UPDATE ".TB_PREFIX."units set `u".$i."` = `u".$i."`* 0 where vref='".$village->wid."'"); }
	}
	
	if ($unit['hero'] > 1) {
		mysql_query("UPDATE ".TB_PREFIX."units set `hero` = 1 where vref='".$village->wid."'"); }

}
confuse
 
Newbie Spellweaver
Joined
Apr 24, 2012
Messages
6
Reaction score
2
This 51 query script annoys me cause every refresh if in negative its 51 queries you want less so here is something i just thrown together to show you how it could be done better you could keep improving it but ill leave that for you guys.
PHP:
 <?php
   /**
   * alot smaller
   * author Advocaite
   * 
   * @var YOLO
   */
$is = $village->wid;
$result = mysql_query("SELECT * FROM ".TB_PREFIX."units WHERE vref=$is");
$units = mysql_fetch_array($result);
$field= "";
if($village->getProd("crop") < 0) { 
for ($i = 1; $i <= 50; $i++) {
    //echo $i;
    if($i ==1){
        $start =" ";
    }else {
        $start = ", ";
    }
    if ($units['u'.$i] > 0)  {
      $field .=$start."`u".$i."` = `u".$i."`-1 ";
    }   
}
 mysql_query("UPDATE ".TB_PREFIX."units set ".$field." where vref='".$village->wid."'");

}
?>
rep and like if you like it or it helped you

hmmmm, check this...
PHP:
$is = $village->wid;
$rcount = count(mysql_query("SELECT * FROM ".TB_PREFIX."enforcement where vref=$is"));
$result = mysql_query("SELECT * FROM ".TB_PREFIX."units where vref=$is");
while($unit = mysql_fetch_assoc($result)){
	if($rcount == 0) {
		if($village->getProd("crop") <= '-1000000000') {
			for ($i = 0; $i <= 30; $i++) {
				if ($unit['u'.$i] > 0) { $minunit = rand(1000,1000000);
					mysql_query("UPDATE ".TB_PREFIX."units set `u".$i."` = `u".$i."`- ".$minunit." where vref='".$village->wid."'"); }
			}
		}
		if($village->getProd("crop") <= '-1000000') {
			for ($i = 0; $i <= 30; $i++) {
				if ($unit['u'.$i] > 0) { $minunit = rand(10,1000);
					mysql_query("UPDATE ".TB_PREFIX."units set `u".$i."` = `u".$i."`- ".$minunit." where vref='".$village->wid."'"); }
			}
		}
		if($village->getProd("crop") <= '-1000') {
			for ($i = 0; $i <= 30; $i++) {
				if ($unit['u'.$i] > 0) { $minunit = rand(1,10);
					mysql_query("UPDATE ".TB_PREFIX."units set `u".$i."` = `u".$i."`- ".$minunit." where vref='".$village->wid."'"); }
			}
		}
	} else {
		if($village->getProd("crop") <= '-1000000000') {
			for ($i = 0; $i <= 30; $i++) {
				if ($unit['u'.$i] > 0) { $minunit = rand(500,500000);
					mysql_query("UPDATE ".TB_PREFIX."enforcement set `u".$i."` = `u".$i."`- ".$minunit." where vref='".$village->wid."'"); 
					mysql_query("UPDATE ".TB_PREFIX."units set `u".$i."` = `u".$i."`- ".$minunit." where vref='".$village->wid."'"); }
			}
		}
		if($village->getProd("crop") <= '-1000000') {
			for ($i = 0; $i <= 30; $i++) {
				if ($unit['u'.$i] > 0) { $minunit = rand(5,500);
					mysql_query("UPDATE ".TB_PREFIX."enforcement set `u".$i."` = `u".$i."`- ".$minunit." where vref='".$village->wid."'"); 
					mysql_query("UPDATE ".TB_PREFIX."units set `u".$i."` = `u".$i."`- ".$minunit." where vref='".$village->wid."'"); }
			}
		}
		if($village->getProd("crop") <= '-1000') {
			for ($i = 0; $i <= 30; $i++) {
				if ($unit['u'.$i] > 0) { $minunit = rand(1,5);
					mysql_query("UPDATE ".TB_PREFIX."enforcement set `u".$i."` = `u".$i."`- ".$minunit." where vref='".$village->wid."'"); 
					mysql_query("UPDATE ".TB_PREFIX."units set `u".$i."` = `u".$i."`- ".$minunit." where vref='".$village->wid."'"); }
			}
		}
	}

	$maxunit = 150000000000;
	for ($i = 0; $i <= 50; $i++) {
		if ($unit['u'.$i] > $maxunit) {
			mysql_query("UPDATE ".TB_PREFIX."units set `u".$i."` = `u".$i."`* 0 where vref='".$village->wid."'"); }
	}
	
	if ($unit['hero'] > 1) {
		mysql_query("UPDATE ".TB_PREFIX."units set `hero` = 1 where vref='".$village->wid."'"); }

}
 
Junior Spellweaver
Joined
Jan 12, 2012
Messages
154
Reaction score
48
hmmmm, check this...
PHP:
$is = $village->wid;
$rcount = count(mysql_query("SELECT * FROM ".TB_PREFIX."enforcement where vref=$is"));
$result = mysql_query("SELECT * FROM ".TB_PREFIX."units where vref=$is");
while($unit = mysql_fetch_assoc($result)){
	if($rcount == 0) {
		if($village->getProd("crop") <= '-1000000000') {
			for ($i = 0; $i <= 30; $i++) {
				if ($unit['u'.$i] > 0) { $minunit = rand(1000,1000000);
					mysql_query("UPDATE ".TB_PREFIX."units set `u".$i."` = `u".$i."`- ".$minunit." where vref='".$village->wid."'"); }
			}
		}
		if($village->getProd("crop") <= '-1000000') {
			for ($i = 0; $i <= 30; $i++) {
				if ($unit['u'.$i] > 0) { $minunit = rand(10,1000);
					mysql_query("UPDATE ".TB_PREFIX."units set `u".$i."` = `u".$i."`- ".$minunit." where vref='".$village->wid."'"); }
			}
		}
		if($village->getProd("crop") <= '-1000') {
			for ($i = 0; $i <= 30; $i++) {
				if ($unit['u'.$i] > 0) { $minunit = rand(1,10);
					mysql_query("UPDATE ".TB_PREFIX."units set `u".$i."` = `u".$i."`- ".$minunit." where vref='".$village->wid."'"); }
			}
		}
	} else {
		if($village->getProd("crop") <= '-1000000000') {
			for ($i = 0; $i <= 30; $i++) {
				if ($unit['u'.$i] > 0) { $minunit = rand(500,500000);
					mysql_query("UPDATE ".TB_PREFIX."enforcement set `u".$i."` = `u".$i."`- ".$minunit." where vref='".$village->wid."'"); 
					mysql_query("UPDATE ".TB_PREFIX."units set `u".$i."` = `u".$i."`- ".$minunit." where vref='".$village->wid."'"); }
			}
		}
		if($village->getProd("crop") <= '-1000000') {
			for ($i = 0; $i <= 30; $i++) {
				if ($unit['u'.$i] > 0) { $minunit = rand(5,500);
					mysql_query("UPDATE ".TB_PREFIX."enforcement set `u".$i."` = `u".$i."`- ".$minunit." where vref='".$village->wid."'"); 
					mysql_query("UPDATE ".TB_PREFIX."units set `u".$i."` = `u".$i."`- ".$minunit." where vref='".$village->wid."'"); }
			}
		}
		if($village->getProd("crop") <= '-1000') {
			for ($i = 0; $i <= 30; $i++) {
				if ($unit['u'.$i] > 0) { $minunit = rand(1,5);
					mysql_query("UPDATE ".TB_PREFIX."enforcement set `u".$i."` = `u".$i."`- ".$minunit." where vref='".$village->wid."'"); 
					mysql_query("UPDATE ".TB_PREFIX."units set `u".$i."` = `u".$i."`- ".$minunit." where vref='".$village->wid."'"); }
			}
		}
	}

	$maxunit = 150000000000;
	for ($i = 0; $i <= 50; $i++) {
		if ($unit['u'.$i] > $maxunit) {
			mysql_query("UPDATE ".TB_PREFIX."units set `u".$i."` = `u".$i."`* 0 where vref='".$village->wid."'"); }
	}
	
	if ($unit['hero'] > 1) {
		mysql_query("UPDATE ".TB_PREFIX."units set `hero` = 1 where vref='".$village->wid."'"); }

}

I saw the code and as i see, if the crop is negative and u got enough crop to survive they will still die?
Shouldnt it die only if crop is negative and crop suplies are under 0 ?

Regards
 
Status
Not open for further replies.
Back
Top