(This post was last modified: 28.12.2011, 11:44 by Felipe Medeiros.)
27.12.2011, 18:24
Below I will post a script to add the statue and paladin on your server.
create the file game_snob.tpl in the folder temnplates and insert the code:
go to the folder include/config and create the file unit_knight_config.php. Insert in the file:
Add in templates/game.tpl:
Add in include/configs/units.php
And add in include/configs/buildings.php:
SQL CODE:
create the file game_snob.tpl in the folder temnplates and insert the code:
PHP Code:
<table>
<tr>
<td><img src="../graphic/big_buildings/statue1.png" title="Estatua" alt="" /></td>
<td>
<h2>Statue ({$village.statue|stage})
</h2>
Locuitorii satului aduc la statuie omagii Paladinului. Daca Paladinul cade in lupta, aici ai posibilitatea sa numesti un soldat ca nou Paladin.
</td>
</tr>
</table><br />
{php}
include("include/configs/unit_knight_config.php");
// nivel statuie
$statue = $this->_tpl_vars['village']['statue'];
if($statue != '0'){
$time = $time * 60 - 1;
$time_s = time() + $time;
// aflam resursele din sat
$village_wood = $this->_tpl_vars['village']['r_wood'];
$village_stone = $this->_tpl_vars['village']['r_stone'];
$village_iron = $this->_tpl_vars['village']['r_iron'];
// aflam id-ul userului
$userid = $this->_tpl_vars['user']['id'];
// codul de securitate
$hkey = $this->_tpl_vars['hkey'];
// pe ce sat este folosind metoda GET
$vill = $_GET['village'];
// selectam date user
$user = mysql_fetch_array(mysql_query("SELECT `knight`,`knight_name`,`knight_village_recruit`,`knight_village` FROM `users` WHERE `id` = '".$userid."'"));
if($user['knight_village'] > 0){
$numar_paladini = mysql_fetch_assoc(mysql_query("SELECT `all_unit_knight` FROM `villages` WHERE `id` = '".$user['knight_village']."'"));
}
// verificam daca se recruteaza vreun paladin
$recruit = mysql_num_rows(mysql_query("SELECT * FROM `recruit` WHERE `villageid` = '".$user['knight_village_recruit']."' AND `unit` = 'unit_knight'"));
if(!$recruit){
mysql_query("UPDATE `users` SET `knight` = '".$numar_paladini['all_unit_knight']."' WHERE `id` = '".$userid."'");
}
$user = mysql_fetch_array(mysql_query("SELECT `knight`,`knight_name`,`knight_village_recruit`,`knight_village` FROM `users` WHERE `id` = '".$userid."'"));
// anulam comanda
if($_GET['do'] == 'drep' && $_GET['hkey'] == $hkey){
mysql_query("UPDATE `users` SET `knight` = '0' WHERE `id` = '".$userid."'");
mysql_query("DELETE FROM `events` WHERE `event_id` = '".$_GET['id']."'");
$recruit_f1 = mysql_fetch_array(mysql_query("SELECT `villageid` FROM `recruit` WHERE `id` = '".$_GET['id']."'"));
mysql_query("UPDATE `villages` SET `r_bh` = `r_bh` - '".$farms."' WHERE `id` = '".$recruit_f1['villageid']."'") or die (mysql_error());
mysql_query("DELETE FROM recruit WHERE id = '".$_GET['id']."'");
header("Location: game.php?village=$vill&screen=statue");
}
// daca recrutam paladinul
if($_GET['recruit'] == 'paladin'){
if($user['knight'] >= '1'){
$error = 'Voê já possui um paladino.';
}else{
mysql_query("UPDATE `villages` SET `r_wood` = `r_wood` - '".$wood."' WHERE `id` = '".$_GET['village']."'") or die (mysql_error());
mysql_query("UPDATE `villages` SET `r_stone` = `r_stone` - '".$stone."' WHERE `id` = '".$_GET['village']."'");
mysql_query("UPDATE `villages` SET `r_iron` = `r_iron` - '".$iron."' WHERE id = '".$_GET['village']."'");
mysql_query("UPDATE `villages` SET `r_bh` = `r_bh` + '".$farms."' WHERE id = '".$_GET['village']."'");
mysql_query("INSERT INTO `recruit` (`unit`,`num_unit`,`num_finished`,`time_finished`,`time_start`,`time_per_unit`,`building`,`villageid`) VALUES ('".$unit."','1','0','".$time_s."','".time()."','".$time."','statue','".$_GET['village']."')") or die (mysql_error());
$select = mysql_query("SELECT * FROM `recruit` WHERE `unit` = 'unit_knight' AND `villageid` = '".$_GET['village']."' ORDER BY id DESC") or die (mysql_error());
$num = mysql_num_rows($select);
if($num > 0){
$array = mysql_fetch_array($select);
mysql_query("INSERT INTO events (`event_time`,`event_type`,`event_id`,`user_id`,`villageid`) VALUES ('".time()."','recruit','".$array['id']."','".$userid."','".$_GET['village']."')") or die (mysql_error());
}
mysql_query("UPDATE `users` SET `knight` = '1' WHERE `id` = '".$userid."'");
mysql_query("UPDATE `users` SET `knight_village_recruit` = '".$_GET['village']."' WHERE `id` = '".$userid."'");
mysql_query("UPDATE `users` SET `knight_village` = '".$_GET['village']."' WHERE `id` = '".$userid."'");
$vill = $_GET['village'];
header("Location: game.php?village=$vill&screen=statue");
}
}
$num = mysql_num_rows(mysql_query("SELECT * FROM `recruit` WHERE `villageid` = '".$vill."' AND building = 'statue'"));
if($num > 0){
{/php}
<table class="vis">
<tr>
<th width="150">Comando</th>
<th width="120">Duração</th>
<th width="150">Termino</th>
<th width="100">Cancelar *</th>
</tr>
{php}
$vil = $_GET['village'];
$o1 = mysql_query("SELECT id FROM villages WHERE userid = '".$userid."'") or die (mysql_error());
while ($array02 = mysql_fetch_array($o1)){
$query03 = mysql_fetch_array(mysql_query("SELECT * FROM recruit WHERE villageid = '".$vill."' AND building = 'statue'"));
if($array02['id'] == $query03['villageid']){
echo '<tr class="lit"><td><img src="../graphic/unit/unit_knight.png" />'.stripslashes(urldecode($user['knight_name'])).'</td><td align="center"><span class="timer">'.format_time($query03['time_finished']-time()+1).'</span></td><td align="center">'.date("d.m.y H:i", $query03['time_finished']).'</td><td><a href="game.php?village='.$vil.'&screen=statue&do=drep&id='.$query03['id'].'&hkey='.$hkey.'">cancelar</a></td></tr>';
}
}
{/php}
</table><br />
{php}
}
if(!empty($error)){
{/php}
<div class="error">{php} echo $error; {/php}</div>
{php}
}
{/php}
<table class="vis" width="100%">
<tr><th width="130">Unidade</th> <th width="40"><center><img src="../graphic/holz.png"></center></th>
<th width="40"><center><img src="../graphic/lehm.png"></center></th>
<th width="40"><center><img src="../graphic/eisen.png"></center></th>
<th width="40"><center><img src="../graphic/face.png"></center></th><th>Duração</th><th>Recrutar</th><th width="240">Localidade</th></tr>
<tr>
<td width="250"><a href="javascript:popup('popup_unit.php?unit={php} echo $unit; {/php}', 520, 520)"> <img src="../graphic/unit/{php} echo $unit; {/php}.png" alt="" />{php} echo stripslashes(urldecode($user['knight_name'])); {/php}</a></td>
<td align="center">{php}echo $wood;{/php}</td>
<td align="center">{php}echo $stone;{/php}</td>
<td align="center">{php}echo $iron;{/php}</td>
<td align="center">{php}echo $farms;{/php}</td>
<td align="center">{php}echo format_time($time+1);{/php}</td>
{php}
include("include/config.php");
include("include/configs/farm_limits.php");
$wood_re = $this->_tpl_vars['village']['r_wood'];
$stone_re = $this->_tpl_vars['village']['r_stone'];
$iron_re = $this->_tpl_vars['village']['r_iron'];
$farms_re = $this->_tpl_vars['village']['r_bh'];
$farms_lvl = $this->_tpl_vars['village']['farm'];
if($wood_re < $wood || $stone_re < $stone || $iron_re < $iron){
$error = '<td class="inactive" align="center">Recursos insuficientes.</td>';
}
if($user['knight'] >= '1'){
$error = '<td class="inactive" align="center">Só é permitido 1 paladino por jogador.</td>';
}
if($farms_re + $farms >= $arr_farm[$farms_lvl]){
$error = '<td class="inactive" align="center">A fazenda não pode prover mais unidades.</td>';
}
if(!empty($error)){
echo $error;
}else{
{/php}
<td align="center"><a href="game.php?village={$village.id}&screen=statue&recruit=paladin">Nomear paladino</a></td>
{php}
}
{/php}
<td align="center">
{php}
$knight_loc = mysql_fetch_assoc(mysql_query("SELECT * FROM `villages` WHERE `id` = '".$user['knight_village']."'"));
if ($knight_loc['all_unit_knight'] > 0) { echo '<a href="game.php?village='.$knight_loc[id].'&screen=overview">'.stripslashes(urldecode($knight_loc['name'])).' ('.$knight_loc['x'].'|'.$knight_loc['y'].') K'.$knight_loc['continent'].'</a>'; } else { echo '<center><b>---</b></center>'; } {/php}</td>
</tr>
</table>
{php}
if ($_GET['do'] == 'change'){
if (strlen(trim($_POST['knight_name'])) < 3 || strlen(trim($_POST['knight_name'])) > 32 ) { $error_1 = 'O nome do paladino deve ter entre 3 e 32 caracteres!'; } else
{
mysql_query("UPDATE users SET knight_name = '".urlencode($_POST['knight_name'])."' WHERE id = '".$userid."'");
header("Location: game.php?village=$vill&screen=statue");
exit;
}
}
{/php}{php} if ($error_1){ {/php}
<span class="error">{php} echo $error_1; {/php}</span>
{php} } {/php}
<br />
<form action="game.php?village={$village.id}&screen=statue&do=change" method="POST">
<table class="vis">
<tr><th>Nome</th><td><input type="text" name="knight_name" value="{php} echo stripslashes(urldecode($user['knight_name'])); {/php}" /><input type="submit" value="Ok" /></td></tr>
</table>
</form>
{php}}{/php}
go to the folder include/config and create the file unit_knight_config.php. Insert in the file:
PHP Code:
<?
$unit = 'unit_knight'; //unit
$farms = 10; //farm used
$wood = 20; //wood cust
$stone = 20; //stone cust
$iron = 40; //iron cust
$time = 5; //time in minutes for create the unit
?>
Add in templates/game.tpl:
PHP Code:
{php}$this->_tpl_vars['allow_screens'][] = "statue";{/php}
Add in include/configs/units.php
PHP Code:
$cl_units->add_unit("Paladin","unit_knight");
$cl_units->set_woodprice("20");
$cl_units->set_stoneprice("20");
$cl_units->set_ironprice("40");
$cl_units->set_bhprice("10");
$cl_units->set_time("600");
$cl_units->set_att("150","1.045");
$cl_units->set_def("250","1.045");
$cl_units->set_defcav("400","1.045");
$cl_units->set_defarcher("150","1.045");
$cl_units->set_speed("800");
$cl_units->set_booty("600");
$cl_units->set_needed(array("statue"=>1));
$cl_units->set_recruit_in("statue");
$cl_units->set_specials(array("no_investigate"));
$cl_units->set_group("cav");
$cl_units->set_col("D");
$cl_units->set_attType("undefined");
$cl_units->set_description("");
And add in include/configs/buildings.php:
PHP Code:
$cl_builds->add_build("Statue","statue");
$cl_builds->set_woodprice("220","1.2");
$cl_builds->set_stoneprice("220","1.2");
$cl_builds->set_ironprice("220","1.2");
$cl_builds->set_bhprice("0","1.17");
$cl_builds->set_time("2000","1.2");
$cl_builds->set_points("0","1.2");
$cl_builds->set_needbuilds(array());
$cl_builds->set_maxstage("1");
$cl_builds->set_specials(array());
$cl_builds->set_description("");
SQL CODE:
PHP Code:
ALTER TABLE `users` ADD `knight` INT( 11 ) NOT NULL DEFAULT '0',
ADD `knight_name` VARCHAR( 200 ) NOT NULL DEFAULT 'Paladin',
ADD `knight_village` INT( 11 ) NOT NULL DEFAULT '0',
ADD `knight_village_recruit` INT( 11 ) NOT NULL DEFAULT '0';
ALTER TABLE `villages` ADD `statue` INT( 11 ) NOT NULL DEFAULT '0'