fix: hero training and revive got messed up

This commit is contained in:
Martin Ambrus
2017-11-22 21:38:57 +01:00
parent 96663574ad
commit c06c62ba6a
4 changed files with 49 additions and 339 deletions
+4
View File
@@ -4635,6 +4635,10 @@ class Automation {
if($villunits['hero'] == 0 && $hdata['trainingtime'] < time() && $hdata['intraining'] == 1){
mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "units SET hero = 1 WHERE vref = ".(int) $hdata['wref']);
$columns[] = 'dead';
$columnValues[] = 0;
$modes[] = null;
$columns[] = 'intraining';
$columnValues[] = 0;
$modes[] = null;
+1 -1
View File
@@ -7500,7 +7500,7 @@ References:
function getHeroDeadReviveOrInTraining($id) {
$id = (int) $id;
$q = "SELECT Count(*) as Total FROM " . TB_PREFIX . "hero WHERE `uid` = $id AND (dead = 0 OR inrevive = 1 OR intraining = 1)";
$q = "SELECT Count(*) as Total FROM " . TB_PREFIX . "hero WHERE `uid` = $id AND dead = 0 AND inrevive = 0 AND intraining = 0";
$result = mysqli_fetch_array(mysqli_query($this->dblink,$q), MYSQLI_ASSOC);
if ($result['Total'] > 0) {
return true;
+8 -3
View File
@@ -208,7 +208,9 @@ class Session {
global $database,$link;
$villageIDs = implode(', ', $this->villages);
$hero = mysqli_fetch_array(
// check if hero unit for this player is present anywhere on the map
$heroUnitRegisters = mysqli_fetch_array(
mysqli_query($database->dblink, '
SELECT
IFNULL((SELECT SUM(hero) from '.TB_PREFIX.'enforcement where `from` IN('.$villageIDs.')), 0) +
@@ -220,9 +222,12 @@ class Session {
MYSQLI_ASSOC
)['herocount'];
$isHeroElsewhere = $database->getHeroDeadReviveOrInTraining($this->uid);
// check if the actual hero is alive or being trained/revived into a living state
$isHeroLivingOrRaising = $database->getHeroDeadReviveOrInTraining($this->uid);
if($isHeroElsewhere && !$hero) {
// if he doesn't register anywhere on the map but is marked as alive,
// we need to kill him
if(!$heroUnitRegisters && $isHeroLivingOrRaising) {
$database->KillMyHero($this->uid);
}
}
+36 -335
View File
@@ -618,343 +618,44 @@ $output.="<tr>
//HERO TRAINING
if($session->tribe == 1){
if(isset($_GET['train']) && $_GET['train'] == 1){
if($session->access != BANNED){
if($count_hero < 3){
mysqli_query($GLOBALS['link'],"INSERT INTO ".TB_PREFIX."hero (`uid`, `wref`, `regeneration`, `unit`, `name`, `level`, `points`, `experience`, `dead`, `health`, `attack`, `defence`, `attackbonus`, `defencebonus`, `trainingtime`, `autoregen`, `intraining`) VALUES ('".$database->escape($session->uid)."', '" . (int) $village->wid . "', '0', '1', '".$database->escape($session->username)."', '0', '5', '0', '0', '100', '0', '0', '0', '0', '".round((time() + ($u1['time'] / SPEED)*3))."', '50', '1')");
mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "units SET `u1` = `u1` - 1 WHERE `vref` = '" . (int) $village->wid . "'");
mysqli_query($GLOBALS['link'],"
UPDATE " . TB_PREFIX . "vdata
SET
`wood` = `wood` - ".(int) $u1['wood'].",
`clay` = `clay` - ".(int) $u1['clay'].",
`iron` = `iron` - ".(int) $u1['iron'].",
`crop` = `crop` - ".(int) $u1['crop']."
WHERE
`wref` = '" . (int) $village->wid . "'");
}
header("Location: build.php?id=".$id."");
exit;
}else{
header("Location: banned.php");
exit;
}
}
if(isset($_GET['train']) && $_GET['train'] == 2){
if($session->access != BANNED){
if($count_hero < 3){
mysqli_query($GLOBALS['link'],"INSERT INTO ".TB_PREFIX."hero (`uid`, `wref`, `regeneration`, `unit`, `name`, `level`, `points`, `experience`, `dead`, `health`, `attack`, `defence`, `attackbonus`, `defencebonus`, `trainingtime`, `autoregen`, `intraining`) VALUES ('".$database->escape($session->uid)."', '" . (int) $village->wid . "', '0', '2', '".$database->escape($session->username)."', '0', '5', '0', '0', '100', '0', '0', '0', '0', '".round((time() + ($u1['time'] / SPEED)*3))."', '50', '1')");
mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "units SET `u2` = `u2` - 1 WHERE `vref` = '" . (int) $village->wid . "'");
mysqli_query($GLOBALS['link'],"
UPDATE " . TB_PREFIX . "vdata
SET
`wood` = `wood` - ".(int) $u2['wood'].",
`clay` = `clay` - ".(int) $u2['clay'].",
`iron` = `iron` - ".(int) $u2['iron'].",
`crop` = `crop` - ".(int) $u2['crop']."
WHERE
`wref` = '" . (int) $village->wid . "'");
}
header("Location: build.php?id=".$id."");
exit;
}else{
header("Location: banned.php");
exit;
}
}
if(isset($_GET['train']) && $_GET['train'] == 3){
if($session->access != BANNED){
mysqli_query($GLOBALS['link'],"INSERT INTO ".TB_PREFIX."hero (`uid`, `wref`, `regeneration`, `unit`, `name`, `level`, `points`, `experience`, `dead`, `health`, `attack`, `defence`, `attackbonus`, `defencebonus`, `trainingtime`, `autoregen`, `intraining`) VALUES ('".$database->escape($session->uid)."', '" . (int) $village->wid . "', '0', '3', '".$database->escape($session->username)."', '0', '5', '0', '0', '100', '0', '0', '0', '0', '".round((time() + ($u3['time'] / SPEED)*3))."', '50', '1')");
mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "units SET `u3` = `u3` - 1 WHERE `vref` = '" . (int) $village->wid . "'");
mysqli_query($GLOBALS['link'],"
UPDATE " . TB_PREFIX . "vdata
SET
`wood` = `wood` - ".(int) $u3['wood'].",
`clay` = `clay` - ".(int) $u3['clay'].",
`iron` = `iron` - ".(int) $u3['iron'].",
`crop` = `crop` - ".(int) $u3['crop']."
WHERE
`wref` = '" . (int) $village->wid . "'");
header("Location: build.php?id=".$id."");
exit;
}else{
header("Location: banned.php");
exit;
}
}
if(isset($_GET['train']) && $_GET['train'] == 5){
if($session->access != BANNED){
if($count_hero < 3){
mysqli_query($GLOBALS['link'],"INSERT INTO ".TB_PREFIX."hero (`uid`, `wref`, `regeneration`, `unit`, `name`, `level`, `points`, `experience`, `dead`, `health`, `attack`, `defence`, `attackbonus`, `defencebonus`, `trainingtime`, `autoregen`, `intraining`) VALUES ('".$database->escape($session->uid)."', '" . (int) $village->wid . "', '0', '5', '".$database->escape($session->username)."', '0', '5', '0', '0', '100', '0', '0', '0', '0', '".round((time() + ($u5['time'] / SPEED)*3))."', '50', '1')");
mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "units SET `u5` = `u5` - 1 WHERE `vref` = '" . (int) $village->wid . "'");
mysqli_query($GLOBALS['link'],"
UPDATE " . TB_PREFIX . "vdata
SET
`wood` = `wood` - ".(int) $u5['wood'].",
`clay` = `clay` - ".(int) $u5['clay'].",
`iron` = `iron` - ".(int) $u5['iron'].",
`crop` = `crop` - ".(int) $u5['crop']."
WHERE
`wref` = '" . (int) $village->wid . "'");
}
header("Location: build.php?id=".$id."");
exit;
}else{
header("Location: banned.php");
exit;
}
}
if(isset($_GET['train']) && $_GET['train'] == 6){
if($session->access != BANNED){
if($count_hero < 3){
mysqli_query($GLOBALS['link'],"INSERT INTO ".TB_PREFIX."hero (`uid`, `wref`, `regeneration`, `unit`, `name`, `level`, `points`, `experience`, `dead`, `health`, `attack`, `defence`, `attackbonus`, `defencebonus`, `trainingtime`, `autoregen`, `intraining`) VALUES ('".$database->escape($session->uid)."', '" . (int) $village->wid . "', '0', '6', '".$database->escape($session->username)."', '0', '5', '0', '0', '100', '0', '0', '0', '0', '".round((time() + ($u6['time'] / SPEED)*3))."', '50', '1')");
mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "units SET `u6` = `u6` - 1 WHERE `vref` = '" . (int) $village->wid . "'");
mysqli_query($GLOBALS['link'],"
UPDATE " . TB_PREFIX . "vdata
SET
`wood` = `wood` - ".(int) $u6['wood'].",
`clay` = `clay` - ".(int) $u6['clay'].",
`iron` = `iron` - ".(int) $u6['iron'].",
`crop` = `crop` - ".(int) $u6['crop']."
WHERE
`wref` = '" . (int) $village->wid . "'");
}
header("Location: build.php?id=".$id."");
exit;
}else{
header("Location: banned.php");
exit;
}
}
}
if($session->tribe == 2){
if(isset($_GET['train']) && $_GET['train'] == 11){
if($session->access != BANNED){
if($count_hero < 3){
mysqli_query($GLOBALS['link'],"INSERT INTO ".TB_PREFIX."hero (`uid`, `wref`, `regeneration`, `unit`, `name`, `level`, `points`, `experience`, `dead`, `health`, `attack`, `defence`, `attackbonus`, `defencebonus`, `trainingtime`, `autoregen`, `intraining`) VALUES ('".$database->escape($session->uid)."', '" . (int) $village->wid . "', '0', '11', '".$database->escape($session->username)."', '0', '5', '0', '0', '100', '0', '0', '0', '0', '".round((time() + ($u11['time'] / SPEED)*3))."', '50', '1')");
mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "units SET `u11` = `u11` - 1 WHERE `vref` = '" . (int) $village->wid . "'");
mysqli_query($GLOBALS['link'],"
UPDATE " . TB_PREFIX . "vdata
SET
`wood` = `wood` - ".(int) $u11['wood'].",
`clay` = `clay` - ".(int) $u11['clay'].",
`iron` = `iron` - ".(int) $u11['iron'].",
`crop` = `crop` - ".(int) $u11['crop']."
WHERE
`wref` = '" . (int) $village->wid . "'");
}
header("Location: build.php?id=".$id."");
exit;
}else{
header("Location: banned.php");
exit;
}
}
if(isset($_GET['train']) && $_GET['train'] == 12){
if($session->access != BANNED){
if($count_hero < 3){
mysqli_query($GLOBALS['link'],"INSERT INTO ".TB_PREFIX."hero (`uid`, `wref`, `regeneration`, `unit`, `name`, `level`, `points`, `experience`, `dead`, `health`, `attack`, `defence`, `attackbonus`, `defencebonus`, `trainingtime`, `autoregen`, `intraining`) VALUES ('".$database->escape($session->uid)."', '" . (int) $village->wid . "', '0', '12', '".$database->escape($session->username)."', '0', '5', '0', '0', '100', '0', '0', '0', '0', '".round((time() + ($u12['time'] / SPEED)*3))."', '50', '1')");
mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "units SET `u12` = `u12` - 1 WHERE `vref` = '" . (int) $village->wid . "'");
mysqli_query($GLOBALS['link'],"
UPDATE " . TB_PREFIX . "vdata
SET
`wood` = `wood` - ".(int) $u12['wood'].",
`clay` = `clay` - ".(int) $u12['clay'].",
`iron` = `iron` - ".(int) $u12['iron'].",
`crop` = `crop` - ".(int) $u12['crop']."
WHERE
`wref` = '" . (int) $village->wid . "'");
}
header("Location: build.php?id=".$id."");
exit;
}else{
header("Location: banned.php");
exit;
}
}
if(isset($_GET['train']) && $_GET['train'] == 13){
if($session->access != BANNED){
if($count_hero < 3){
mysqli_query($GLOBALS['link'],"INSERT INTO ".TB_PREFIX."hero (`uid`, `wref`, `regeneration`, `unit`, `name`, `level`, `points`, `experience`, `dead`, `health`, `attack`, `defence`, `attackbonus`, `defencebonus`, `trainingtime`, `autoregen`, `intraining`) VALUES ('".$database->escape($session->uid)."', '" . (int) $village->wid . "', '0', '13', '".$database->escape($session->username)."', '0', '5', '0', '0', '100', '0', '0', '0', '0', '".round((time() + ($u13['time'] / SPEED)*3))."', '50', '1')");
mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "units SET `u13` = `u13` - 1 WHERE `vref` = '" . (int) $village->wid . "'");
mysqli_query($GLOBALS['link'],"
UPDATE " . TB_PREFIX . "vdata
SET
`wood` = `wood` - ".(int) $u13['wood'].",
`clay` = `clay` - ".(int) $u13['clay'].",
`iron` = `iron` - ".(int) $u13['iron'].",
`crop` = `crop` - ".(int) $u13['crop']."
WHERE
`wref` = '" . (int) $village->wid . "'");
}
header("Location: build.php?id=".$id."");
exit;
}else{
header("Location: banned.php");
exit;
}
}
if(isset($_GET['train']) && $_GET['train'] == 15){
if($session->access != BANNED){
if($count_hero < 3){
mysqli_query($GLOBALS['link'],"INSERT INTO ".TB_PREFIX."hero (`uid`, `wref`, `regeneration`, `unit`, `name`, `level`, `points`, `experience`, `dead`, `health`, `attack`, `defence`, `attackbonus`, `defencebonus`, `trainingtime`, `autoregen`, `intraining`) VALUES ('".$database->escape($session->uid)."', '" . (int) $village->wid . "', '0', '15', '".$database->escape($session->username)."', '0', '5', '0', '0', '100', '0', '0', '0', '0', '".round((time() + ($u15['time'] / SPEED)*3))."', '50', '1')");
mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "units SET `u15` = `u15` - 1 WHERE `vref` = '" . (int) $village->wid . "'");
mysqli_query($GLOBALS['link'],"
UPDATE " . TB_PREFIX . "vdata
SET
`wood` = `wood` - ".(int) $u15['wood'].",
`clay` = `clay` - ".(int) $u15['clay'].",
`iron` = `iron` - ".(int) $u15['iron'].",
`crop` = `crop` - ".(int) $u15['crop']."
WHERE
`wref` = '" . (int) $village->wid . "'");
}
header("Location: build.php?id=".$id."");
exit;
}else{
header("Location: banned.php");
exit;
}
}
if(isset($_GET['train']) && $_GET['train'] == 16){
if($session->access != BANNED){
if($count_hero < 3){
mysqli_query($GLOBALS['link'],"INSERT INTO ".TB_PREFIX."hero (`uid`, `wref`, `regeneration`, `unit`, `name`, `level`, `points`, `experience`, `dead`, `health`, `attack`, `defence`, `attackbonus`, `defencebonus`, `trainingtime`, `autoregen`, `intraining`) VALUES ('".$database->escape($session->uid)."', '" . (int) $village->wid . "', '0', '16', '".$database->escape($session->username)."', '0', '5', '0', '0', '100', '0', '0', '0', '0', '".round((time() + ($u16['time'] / SPEED)*3))."', '50', '1')");
mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "units SET `u16` = `u16` - 1 WHERE `vref` = '" . (int) $village->wid . "'");
mysqli_query($GLOBALS['link'],"
UPDATE " . TB_PREFIX . "vdata
SET
`wood` = `wood` - ".(int) $u16['wood'].",
`clay` = `clay` - ".(int) $u16['clay'].",
`iron` = `iron` - ".(int) $u16['iron'].",
`crop` = `crop` - ".(int) $u16['crop']."
WHERE
`wref` = '" . (int) $village->wid . "'");
}
header("Location: build.php?id=".$id."");
exit;
}else{
header("Location: banned.php");
exit;
}
}
if (isset($_GET['train'])) {
$validationArray = [];
switch ($session->tribe) {
case 1: $validationArray = [1, 2, 3, 5, 6];
break;
case 2: $validationArray = [11, 12, 13, 15, 16];
break;
case 3: $validationArray = [21, 22, 24, 25, 26];
break;
}
if($session->tribe == 3){
if(isset($_GET['train']) && $_GET['train'] == 21){
if($session->access != BANNED){
if($count_hero < 3){
mysqli_query($GLOBALS['link'],"INSERT INTO ".TB_PREFIX."hero (`uid`, `wref`, `regeneration`, `unit`, `name`, `level`, `points`, `experience`, `dead`, `health`, `attack`, `defence`, `attackbonus`, `defencebonus`, `trainingtime`, `autoregen`, `intraining`) VALUES ('".$database->escape($session->uid)."', '" . (int) $village->wid . "', '0', '21', '".$database->escape($session->username)."', '0', '5', '0', '0', '100', '0', '0', '0', '0', '".round((time() + ($u21['time'] / SPEED)*3))."', '50', '1')");
mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "units SET `u21` = `u21` - 1 WHERE `vref` = '" . (int) $village->wid . "'");
mysqli_query($GLOBALS['link'],"
UPDATE " . TB_PREFIX . "vdata
SET
`wood` = `wood` - ".(int) $u21['wood'].",
`clay` = `clay` - ".(int) $u21['clay'].",
`iron` = `iron` - ".(int) $u21['iron'].",
`crop` = `crop` - ".(int) $u21['crop']."
WHERE
`wref` = '" . (int) $village->wid . "'");
}
header("Location: build.php?id=".$id."");
exit;
}else{
header("Location: banned.php");
exit;
}
}
if(isset($_GET['train']) && $_GET['train'] == 22){
if($session->access != BANNED){
if($count_hero < 3){
mysqli_query($GLOBALS['link'],"INSERT INTO ".TB_PREFIX."hero (`uid`, `wref`, `regeneration`, `unit`, `name`, `level`, `points`, `experience`, `dead`, `health`, `attack`, `defence`, `attackbonus`, `defencebonus`, `trainingtime`, `autoregen`, `intraining`) VALUES ('".$database->escape($session->uid)."', '" . (int) $village->wid . "', '0', '22', '".$database->escape($session->username)."', '0', '5', '0', '0', '100', '0', '0', '0', '0', '".round((time() + ($u22['time'] / SPEED)*3))."', '50', '1')");
mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "units SET `u22` = `u22` - 1 WHERE `vref` = '" . (int) $village->wid . "'");
mysqli_query($GLOBALS['link'],"
UPDATE " . TB_PREFIX . "vdata
SET
`wood` = `wood` - ".(int) $u22['wood'].",
`clay` = `clay` - ".(int) $u22['clay'].",
`iron` = `iron` - ".(int) $u22['iron'].",
`crop` = `crop` - ".(int) $u22['crop']."
WHERE
`wref` = '" . (int) $village->wid . "'");
}
header("Location: build.php?id=".$id."");
exit;
}else{
header("Location: banned.php");
exit;
}
}
if(isset($_GET['train']) && $_GET['train'] == 24){
if($session->access != BANNED){
if($count_hero < 3){
mysqli_query($GLOBALS['link'],"INSERT INTO ".TB_PREFIX."hero (`uid`, `wref`, `regeneration`, `unit`, `name`, `level`, `points`, `experience`, `dead`, `health`, `attack`, `defence`, `attackbonus`, `defencebonus`, `trainingtime`, `autoregen`, `intraining`) VALUES ('".$database->escape($session->uid)."', '" . (int) $village->wid . "', '0', '24', '".$database->escape($session->username)."', '0', '5', '0', '0', '100', '0', '0', '0', '0', '".round((time() + ($u24['time'] / SPEED)*3))."', '50', '1')");
mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "units SET `u24` = `u24` - 1 WHERE `vref` = '" . (int) $village->wid . "'");
mysqli_query($GLOBALS['link'],"
UPDATE " . TB_PREFIX . "vdata
SET
`wood` = `wood` - ".(int) $u24['wood'].",
`clay` = `clay` - ".(int) $u24['clay'].",
`iron` = `iron` - ".(int) $u24['iron'].",
`crop` = `crop` - ".(int) $u24['crop']."
WHERE
`wref` = '" . (int) $village->wid . "'");
}
header("Location: build.php?id=".$id."");
exit;
}else{
header("Location: banned.php");
exit;
}
}
if(isset($_GET['train']) && $_GET['train'] == 25){
if($session->access != BANNED){
if($count_hero < 3){
mysqli_query($GLOBALS['link'],"INSERT INTO ".TB_PREFIX."hero (`uid`, `wref`, `regeneration`, `unit`, `name`, `level`, `points`, `experience`, `dead`, `health`, `attack`, `defence`, `attackbonus`, `defencebonus`, `trainingtime`, `autoregen`, `intraining`) VALUES ('".$database->escape($session->uid)."', '" . (int) $village->wid . "', '0', '25', '".$database->escape($session->username)."', '0', '5', '0', '0', '100', '0', '0', '0', '0', '".round((time() + ($u25['time'] / SPEED)*3))."', '50', '1')");
mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "units SET `u25` = `u25` - 1 WHERE `vref` = '" . (int) $village->wid . "'");
mysqli_query($GLOBALS['link'],"
UPDATE " . TB_PREFIX . "vdata
SET
`wood` = `wood` - ".(int) $u25['wood'].",
`clay` = `clay` - ".(int) $u25['clay'].",
`iron` = `iron` - ".(int) $u25['iron'].",
`crop` = `crop` - ".(int) $u25['crop']."
WHERE
`wref` = '" . (int) $village->wid . "'");
}
header("Location: build.php?id=".$id."");
exit;
}else{
header("Location: banned.php");
exit;
}
}
if(isset($_GET['train']) && $_GET['train'] == 26){
if($session->access != BANNED){
if($count_hero < 3){
mysqli_query($GLOBALS['link'],"INSERT INTO ".TB_PREFIX."hero (`uid`, `wref`, `regeneration`, `unit`, `name`, `level`, `points`, `experience`, `dead`, `health`, `attack`, `defence`, `attackbonus`, `defencebonus`, `trainingtime`, `autoregen`, `intraining`) VALUES ('".$database->escape($session->uid)."', '" . (int) $village->wid . "', '0', '26', '".$database->escape($session->username)."', '0', '5', '0', '0', '100', '0', '0', '0', '0', '".round((time() + ($u26['time'] / SPEED)*3))."', '50', '1')");
mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "units SET `u26` = `u26` - 1 WHERE `vref` = '" . (int) $village->wid . "'");
mysqli_query($GLOBALS['link'],"
UPDATE " . TB_PREFIX . "vdata
SET
`wood` = `wood` - ".(int) $u26['wood'].",
`clay` = `clay` - ".(int) $u26['clay'].",
`iron` = `iron` - ".(int) $u26['iron'].",
`crop` = `crop` - ".(int) $u26['crop']."
WHERE
`wref` = '" . (int) $village->wid . "'");
}
header("Location: build.php?id=".$id."");
exit;
}else{
header("Location: banned.php");
exit;
}
}
}
// check for a valid unit value
if (in_array($_GET['train'], $validationArray)) {
if($session->access != BANNED){
if($count_hero < 3){
$unitID = $_GET['train'];
mysqli_query($GLOBALS['link'],"INSERT INTO ".TB_PREFIX."hero (`uid`, `wref`, `regeneration`, `unit`, `name`, `level`, `points`, `experience`, `dead`, `health`, `attack`, `defence`, `attackbonus`, `defencebonus`, `trainingtime`, `autoregen`, `intraining`) VALUES (".$database->escape($session->uid).", " . (int) $village->wid . ", 0, ".$unitID.", '".$database->escape($session->username)."', 0, 5, 0, 0, 100, 0, 0, 0, 0, ".round((time() + (${'u'.$unitID}['time'] / SPEED)*3)).", 50, 1)");
mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "units SET `u$unitID` = `u$unitID` - 1 WHERE `vref` = " . (int) $village->wid);
mysqli_query($GLOBALS['link'],"
UPDATE " . TB_PREFIX . "vdata
SET
`wood` = `wood` - ".(int) ${'u'.$unitID}['wood'].",
`clay` = `clay` - ".(int) ${'u'.$unitID}['clay'].",
`iron` = `iron` - ".(int) ${'u'.$unitID}['iron'].",
`crop` = `crop` - ".(int) ${'u'.$unitID}['crop']."
WHERE
`wref` = " . (int) $village->wid);
}
header("Location: build.php?id=".$id."");
exit;
}else{
header("Location: banned.php");
exit;
}
}
}
echo $output;
}