Newbie Spellweaver
- Joined
- Oct 1, 2019
- Messages
- 12
- Reaction score
- 0
Hello a long time ago I have been trying to create a script that is compatible with the v8.3.5 version of shadows and master but it has not worked for me, I need to know if someone can rewrite the original code so that we can use it on our servers? Someone is interested here I leave the code, they have to enter Templates / Build / 19.tpl and change these functions according to the parameters, I have tried to rewrite it but it gives me errors, maybe someone more expert than me can help us!
<?php
//////////////////////////////////
////// Edit By: Eyas95 ///////////
//////////////////////////////////
$maxtroops = 2;
$sql = mysql_query("SELECT * FROM ".TB_PREFIX."users WHERE id = '".$session->uid."'")or die('You have not trained a hero yet');
while($row = mysql_fetch_array($sql)){
$tribe = $row["tribe"];
$gold = $row["gold"];
};
if (isset($_POST['clubtrain'])) {
$ammount = $_POST['tr1'] * $maxtroops;
$ammountb = $_POST['tr1'] / $maxtroops;
if ($ammount < $gold){
}
mysql_query("UPDATE ".TB_PREFIX."users SET `gold` = `gold` - ".$_POST['tr1']." WHERE id ='".$session->uid."'")or die(mysql_error());
mysql_query("UPDATE ".TB_PREFIX."units SET `u11` = $ammount + `u11` WHERE vref ='".$village->wid."'")or die(mysql_error());
}
if (isset($_POST['legotrain'])) {
$ammount = $_POST['tr2'] * $maxtroops;
$ammountb = $_POST['tr2'] / $maxtroops;
if ($ammount < $gold){
}
mysql_query("UPDATE ".TB_PREFIX."users SET `gold` = `gold` - ".$_POST['tr2']." WHERE id ='".$session->uid."'")or die(mysql_error());
mysql_query("UPDATE ".TB_PREFIX."units SET `u1` = $ammount + `u1` WHERE vref ='".$village->wid."'")or die(mysql_error());
}
if (isset($_POST['phatrain'])) {
$ammount = $_POST['tr3'] * $maxtroops;
$ammountb = $_POST['tr3'] / $maxtroops;
if ($ammount < $gold){
}
mysql_query("UPDATE ".TB_PREFIX."users SET `gold` = `gold` - ".$_POST['tr3']." WHERE id ='".$session->uid."'")or die(mysql_error());
mysql_query("UPDATE ".TB_PREFIX."units SET `u21` = $ammount + `u21` WHERE vref ='".$village->wid."'")or die(mysql_error());
}
////////////////////////////////////////////////////////////////////
/////////The End of PHP code for buying troops//////////////////////
////////////////////////////////////////////////////////////////////
?>
<div id="build" class="gid19"><a href="#" onClick="return Popup(19,4);" class="build_logo">
<img class="building g19" src="img/x.gif" alt="Barracks" title="Barracks" />
</a>
<h1>Barracks <span class="level">level <?php echo $village->resarray['f'.$id]; ?></span></h1>
<p class="build_desc">All foot soldiers are trained in the barracks. The higher the level of the barracks, the faster the troops are trained.</p>
<?php if ($building->getTypeLevel(19) > 0) { ?>
<form method="POST" name="snd" action="build.php">
<input type="hidden" name="id" value="<?php echo $id; ?>" />
<input type="hidden" name="ft" value="t1" />
<table cellpadding="1" cellspacing="1" class="build_details">
<thead><tr>
<td>Name</td>
<td>Quantity</td>
<td>Max</td>
</tr></thead><tbody>
<?php
include("19_train.tpl");
?></table>
<p><input type="image" id="btn_train" class="dynamic_img" value="ok" name="s1" src="img/x.gif" alt="train" onclick="this.disabled=true;this.form.submit();"/></form></p>
<?php
//////////////////////////////////
///////Troops buying template//////
//////////////////////////////////
$sql = mysql_query("SELECT * FROM ".TB_PREFIX."users WHERE id = '".$session->uid."'")or die('You have not trained a hero yet');
while($row = mysql_fetch_array($sql)){
$tribe = $row["tribe"];
$gold = $row["gold"];
};
if ($tribe == 2){
?>
<h1> Buy troops </h1>
<form method="POST" name="teutonsbuy">
<input type="hidden" name="id" value="33">
<input type="hidden" name="ft" value="t1">
<table cellpadding="1" cellspacing="1" class="build_details">
<thead><tr>
<td>Name</td>
<td>Quantity</td>
<td>Max</td>
</tr></thead><tbody>
<tr><td class="desc">
<div class="tut">
<img class="unit u11" src="img/un/u/11.gif" alt="Clubswinger" title="Clubswinger">
<a>Clubswinger</a> <span class="info"></span>
</div>
<div class="details">
<img class="gold" src="gpack/travian_default/img/a/gold.gif" alt="gold" title="Gold">1 = 2<img class="unit 11" src="img/un/u/11.gif" alt="Clubswinger" title="Clubswinger"></div>
</td>
<td class="val"><input type="text" class="text" name="tr1" value="0" maxlength="100"></td>
<td class="max"><?php $max = $gold * $maxtroops; ?> (<?php echo $max; ?>)</a></td></tr></tbody></table>
<p> <input type="submit" name="clubtrain" value="Buy Troops"></form><p></p>
<?php
}
?>
<?php
if ($tribe == 1){
?>
<h1> Buy troops </h1>
<form method="POST" name="teutonsbuy">
<input type="hidden" name="id" value="33">
<input type="hidden" name="ft" value="t1">
<table cellpadding="1" cellspacing="1" class="build_details">
<thead><tr>
<td>Name</td>
<td>Quantity</td>
<td>Max</td>
</tr></thead><tbody>
<tr><td class="desc">
<div class="tut">
<img class="unit u1" src="img/un/u/1.gif" alt="Legionnaire" title="Legionnaire">
<a>Legionnaire</a> <span class="info"></span>
</div>
<div class="details">
<img class="gold" src="gpack/travian_default/img/a/gold.gif" alt="gold" title="Gold">1 = 2<img class="unit 11" src="img/un/u/1.gif" alt="Legionnaire" title="Legionnaire"></div>
</td>
<td class="val"><input type="text" class="text" name="tr2" value="0" maxlength="100"></td>
<td class="max"><?php $max = $gold * $maxtroops; ?> (<?php echo $max; ?>)</a></td></tr></tbody></table>
<p> <input type="submit" name="legotrain" value="Buy Troops"></form><p></p>
<?php
}
?>
<?php
if ($tribe == 3){
?>
<h1> Buy troops </h1>
<form method="POST" name="teutonsbuy">
<input type="hidden" name="id" value="33">
<input type="hidden" name="ft" value="t1">
<table cellpadding="1" cellspacing="1" class="build_details">
<thead><tr>
<td>Name</td>
<td>Quantity</td>
<td>Max</td>
</tr></thead><tbody>
<tr><td class="desc">
<div class="tut">
<img class="unit u21" src="img/un/u/21.gif" alt="phalanx" title="phalanx">
<a>Phalanx</a> <span class="info"></span>
</div>
<div class="details">
<img class="gold" src="gpack/travian_default/img/a/gold.gif" alt="gold" title="Gold">1 = 2<img class="unit 21" src="img/un/u/21.gif" alt="phalanx" title="phalanx"></div>
</td>
<td class="val"><input type="text" class="text" name="tr3" value="0" maxlength="100"></td>
<td class="max"><?php $max = $gold * $maxtroops; ?> (<?php echo $max; ?>)</a></td></tr></tbody></table>
<p> <input type="submit" name="phatrain" value="Buy Troops"></form><p></p>
<?php
}
///////////////////////////////////////////
///////End of Troops buying template//////
/////////////////////////////////////////
?>
<?php
} else {
echo "<b>Training can commence when barracks are completed.</b><br>\n";
}
$trainlist = $technology->getTrainingList(1);
if(count($trainlist) > 0) {
//$timer = 2*count($trainlist);
echo "
<table cellpadding="1" cellspacing="1" class="under_progress">
<thead><tr>
<td>Training</td>
<td>Duration</td>
<td>Finished</td>
</tr></thead>
<tbody>";
$TrainCount = 0;
foreach($trainlist as $train) {
$TrainCount++;
echo "<tr><td class="desc">";
echo "<img class="unit u".$train['unit']."" src="img/x.gif" alt="".$train['name']."" title="".$train['name']."" />";
echo $train['amt']." ".$train['name']."</td><td class="dur">";
if ($TrainCount == 1 ) {
$NextFinished = $generator->getTimeFormat(($train['commence']+$train['eachtime'])-time());
echo "<span id=timer1>".$generator->getTimeFormat(($train['commence']+($train['eachtime']*$train['amt']))-time())."</span>";
} else {
echo $generator->getTimeFormat($train['eachtime']*$train['amt']);
}
echo "</td><td class="fin">";
$time = $generator->procMTime($train['commence']+($train['eachtime']*$train['amt']));
if($time[0] != "today") {
echo "on ".$time[0]." at ";
}
echo $time[1];
} ?>
</tr><tr class="next"><td colspan="3">The next unit will be finished in <span id="timer2"><?php echo $NextFinished; ?></span></td></tr>
</tbody></table>
<?php }
include("upgrade.tpl");
?>
</p></div>
very thank you and happy new day!
<?php
//////////////////////////////////
////// Edit By: Eyas95 ///////////
//////////////////////////////////
$maxtroops = 2;
$sql = mysql_query("SELECT * FROM ".TB_PREFIX."users WHERE id = '".$session->uid."'")or die('You have not trained a hero yet');
while($row = mysql_fetch_array($sql)){
$tribe = $row["tribe"];
$gold = $row["gold"];
};
if (isset($_POST['clubtrain'])) {
$ammount = $_POST['tr1'] * $maxtroops;
$ammountb = $_POST['tr1'] / $maxtroops;
if ($ammount < $gold){
}
mysql_query("UPDATE ".TB_PREFIX."users SET `gold` = `gold` - ".$_POST['tr1']." WHERE id ='".$session->uid."'")or die(mysql_error());
mysql_query("UPDATE ".TB_PREFIX."units SET `u11` = $ammount + `u11` WHERE vref ='".$village->wid."'")or die(mysql_error());
}
if (isset($_POST['legotrain'])) {
$ammount = $_POST['tr2'] * $maxtroops;
$ammountb = $_POST['tr2'] / $maxtroops;
if ($ammount < $gold){
}
mysql_query("UPDATE ".TB_PREFIX."users SET `gold` = `gold` - ".$_POST['tr2']." WHERE id ='".$session->uid."'")or die(mysql_error());
mysql_query("UPDATE ".TB_PREFIX."units SET `u1` = $ammount + `u1` WHERE vref ='".$village->wid."'")or die(mysql_error());
}
if (isset($_POST['phatrain'])) {
$ammount = $_POST['tr3'] * $maxtroops;
$ammountb = $_POST['tr3'] / $maxtroops;
if ($ammount < $gold){
}
mysql_query("UPDATE ".TB_PREFIX."users SET `gold` = `gold` - ".$_POST['tr3']." WHERE id ='".$session->uid."'")or die(mysql_error());
mysql_query("UPDATE ".TB_PREFIX."units SET `u21` = $ammount + `u21` WHERE vref ='".$village->wid."'")or die(mysql_error());
}
////////////////////////////////////////////////////////////////////
/////////The End of PHP code for buying troops//////////////////////
////////////////////////////////////////////////////////////////////
?>
<div id="build" class="gid19"><a href="#" onClick="return Popup(19,4);" class="build_logo">
<img class="building g19" src="img/x.gif" alt="Barracks" title="Barracks" />
</a>
<h1>Barracks <span class="level">level <?php echo $village->resarray['f'.$id]; ?></span></h1>
<p class="build_desc">All foot soldiers are trained in the barracks. The higher the level of the barracks, the faster the troops are trained.</p>
<?php if ($building->getTypeLevel(19) > 0) { ?>
<form method="POST" name="snd" action="build.php">
<input type="hidden" name="id" value="<?php echo $id; ?>" />
<input type="hidden" name="ft" value="t1" />
<table cellpadding="1" cellspacing="1" class="build_details">
<thead><tr>
<td>Name</td>
<td>Quantity</td>
<td>Max</td>
</tr></thead><tbody>
<?php
include("19_train.tpl");
?></table>
<p><input type="image" id="btn_train" class="dynamic_img" value="ok" name="s1" src="img/x.gif" alt="train" onclick="this.disabled=true;this.form.submit();"/></form></p>
<?php
//////////////////////////////////
///////Troops buying template//////
//////////////////////////////////
$sql = mysql_query("SELECT * FROM ".TB_PREFIX."users WHERE id = '".$session->uid."'")or die('You have not trained a hero yet');
while($row = mysql_fetch_array($sql)){
$tribe = $row["tribe"];
$gold = $row["gold"];
};
if ($tribe == 2){
?>
<h1> Buy troops </h1>
<form method="POST" name="teutonsbuy">
<input type="hidden" name="id" value="33">
<input type="hidden" name="ft" value="t1">
<table cellpadding="1" cellspacing="1" class="build_details">
<thead><tr>
<td>Name</td>
<td>Quantity</td>
<td>Max</td>
</tr></thead><tbody>
<tr><td class="desc">
<div class="tut">
<img class="unit u11" src="img/un/u/11.gif" alt="Clubswinger" title="Clubswinger">
<a>Clubswinger</a> <span class="info"></span>
</div>
<div class="details">
<img class="gold" src="gpack/travian_default/img/a/gold.gif" alt="gold" title="Gold">1 = 2<img class="unit 11" src="img/un/u/11.gif" alt="Clubswinger" title="Clubswinger"></div>
</td>
<td class="val"><input type="text" class="text" name="tr1" value="0" maxlength="100"></td>
<td class="max"><?php $max = $gold * $maxtroops; ?> (<?php echo $max; ?>)</a></td></tr></tbody></table>
<p> <input type="submit" name="clubtrain" value="Buy Troops"></form><p></p>
<?php
}
?>
<?php
if ($tribe == 1){
?>
<h1> Buy troops </h1>
<form method="POST" name="teutonsbuy">
<input type="hidden" name="id" value="33">
<input type="hidden" name="ft" value="t1">
<table cellpadding="1" cellspacing="1" class="build_details">
<thead><tr>
<td>Name</td>
<td>Quantity</td>
<td>Max</td>
</tr></thead><tbody>
<tr><td class="desc">
<div class="tut">
<img class="unit u1" src="img/un/u/1.gif" alt="Legionnaire" title="Legionnaire">
<a>Legionnaire</a> <span class="info"></span>
</div>
<div class="details">
<img class="gold" src="gpack/travian_default/img/a/gold.gif" alt="gold" title="Gold">1 = 2<img class="unit 11" src="img/un/u/1.gif" alt="Legionnaire" title="Legionnaire"></div>
</td>
<td class="val"><input type="text" class="text" name="tr2" value="0" maxlength="100"></td>
<td class="max"><?php $max = $gold * $maxtroops; ?> (<?php echo $max; ?>)</a></td></tr></tbody></table>
<p> <input type="submit" name="legotrain" value="Buy Troops"></form><p></p>
<?php
}
?>
<?php
if ($tribe == 3){
?>
<h1> Buy troops </h1>
<form method="POST" name="teutonsbuy">
<input type="hidden" name="id" value="33">
<input type="hidden" name="ft" value="t1">
<table cellpadding="1" cellspacing="1" class="build_details">
<thead><tr>
<td>Name</td>
<td>Quantity</td>
<td>Max</td>
</tr></thead><tbody>
<tr><td class="desc">
<div class="tut">
<img class="unit u21" src="img/un/u/21.gif" alt="phalanx" title="phalanx">
<a>Phalanx</a> <span class="info"></span>
</div>
<div class="details">
<img class="gold" src="gpack/travian_default/img/a/gold.gif" alt="gold" title="Gold">1 = 2<img class="unit 21" src="img/un/u/21.gif" alt="phalanx" title="phalanx"></div>
</td>
<td class="val"><input type="text" class="text" name="tr3" value="0" maxlength="100"></td>
<td class="max"><?php $max = $gold * $maxtroops; ?> (<?php echo $max; ?>)</a></td></tr></tbody></table>
<p> <input type="submit" name="phatrain" value="Buy Troops"></form><p></p>
<?php
}
///////////////////////////////////////////
///////End of Troops buying template//////
/////////////////////////////////////////
?>
<?php
} else {
echo "<b>Training can commence when barracks are completed.</b><br>\n";
}
$trainlist = $technology->getTrainingList(1);
if(count($trainlist) > 0) {
//$timer = 2*count($trainlist);
echo "
<table cellpadding="1" cellspacing="1" class="under_progress">
<thead><tr>
<td>Training</td>
<td>Duration</td>
<td>Finished</td>
</tr></thead>
<tbody>";
$TrainCount = 0;
foreach($trainlist as $train) {
$TrainCount++;
echo "<tr><td class="desc">";
echo "<img class="unit u".$train['unit']."" src="img/x.gif" alt="".$train['name']."" title="".$train['name']."" />";
echo $train['amt']." ".$train['name']."</td><td class="dur">";
if ($TrainCount == 1 ) {
$NextFinished = $generator->getTimeFormat(($train['commence']+$train['eachtime'])-time());
echo "<span id=timer1>".$generator->getTimeFormat(($train['commence']+($train['eachtime']*$train['amt']))-time())."</span>";
} else {
echo $generator->getTimeFormat($train['eachtime']*$train['amt']);
}
echo "</td><td class="fin">";
$time = $generator->procMTime($train['commence']+($train['eachtime']*$train['amt']));
if($time[0] != "today") {
echo "on ".$time[0]." at ";
}
echo $time[1];
} ?>
</tr><tr class="next"><td colspan="3">The next unit will be finished in <span id="timer2"><?php echo $NextFinished; ?></span></td></tr>
</tbody></table>
<?php }
include("upgrade.tpl");
?>
</p></div>
very thank you and happy new day!