Different trainQueue and not only One

Mods for Devana, along with instructions

Different trainQueue and not only One

Postby Concarster » Sun Feb 07, 2010 10:37 pm

Different trainQueue and not only One.
As the title said i have implemented this on my game.
Right now i have 5 different trainQueue but i only explain 4 here.
1... for Barracks =u_queue this the normal trainQueue for devana than in
my game it only recruit now foot troops or ( Spearman
,Swordsman ,Elite Swordsman, Bowman and Crossbowman)
2... for Stable=us_queue this recruit only cavalry units ( Knight, Ranger
,Scout ,Colonist)
3... For Port =uvote_queue this recruit only vote (Warship ,Transport ship)
4... For Sshop=ubat_queue this recruit only (Battering ram, Catapult)

Those trainQueue are working perfect right now on my game , is a long work to do that cause you need to create new Function in function.php and alter some function in order to everything work fine ,and create new pages for the game.
So is any one is interested let me know and i explain everything
Concarster
footman
 
Posts: 114
Joined: Sat Jan 03, 2009 11:42 pm
Location: Knoxville Tn

Re: Different trainQueue and not only One

Postby Concarster » Mon Feb 08, 2010 9:41 am

Ok buddy here are all the instruction to do this.
This is a long work , i will explain step after step what i did .
i will explain the process for one trainQueue
after that if you want to implement another trainQueue you need to repeat all this step.
As this , is long work , i don't have time to put all the info today. Patient Please
As usual the code is working perfect on my game , but no one know exactly what happen next in programing languages .
The first Step to do this
1... Backup all the file before touching anything . this way if you find some problem you can easily go back to the original file without problem.

Now the second Step.
2... Create another table in you database, this table is similar to the u_queue
than we have in Devana but we need to change the name for our trainQueue

us_queue this will be for our Cavalry troops

Table structure for table `us_queue`
--

Code: Select all
CREATE TABLE IF NOT EXISTS `us_queue` (
  `town` int(10) unsigned NOT NULL default '0',
  `type` int(10) unsigned NOT NULL default '0',
  `quantity` int(10) unsigned NOT NULL default '0',
  `dueTime` datetime NOT NULL default '0000-00-00 00:00:00',
  UNIQUE KEY `Index_1` (`town`,`type`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;


3...Now we need to create our functions over function.php Please backup your function.php just in case.

Our first Function over function.php .Is better than you go all the way down and create your function at the end with some explanation about what you do there for easy understood.

A...function get_us

Code: Select all
function get_us($id)
{
global $db_id, $tdif;

$query="select timediff(dueTime".$tdif.", now()), type, quantity from us_queue where town=".$id." order by dueTime asc";
$result=mysql_query($query, $db_id); $uqs=array();
for ($i=0; $row=mysql_fetch_row($result); $i++) $uqs[$i]=$row;
return $uqs;
}

we are created here the function to call our cavalry units with our $uqs array.

B...function check_us

Code: Select all
function check_us($id)
{
global $db_id, $tdif;
$town=town($id);
$data=explode("-", $town[7]);

$query="select timediff(dueTime".$tdif.", now()), type, quantity from us_queue where town=".$id." order by dueTime asc";
$result=mysql_query($query, $db_id);
for (; $row=mysql_fetch_row($result); )
  if ($row[0][0]=="-")
  {
   $data[$row[1]]+=$row[2]; $d=implode("-", $data);
   $query="update towns set army='".$d."' where id=".$id;
   mysql_query($query, $db_id);
   $query="delete from us_queue where town=".$id." and type=".$row[1];
   mysql_query($query, $db_id);
  }
}


We are created the function than updated our data with our new units and delete from us_queue the troops as soon as the training queue is finishing.

C...function get_unss

Code: Select all
function get_unss($id)
{
global $db_id;

$query="select type from us_queue where town=".$id;
$result=mysql_query($query, $db_id);
$u=array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
for ($i=0; $row=mysql_fetch_row($result); $i++) $u[$row[0]]=1;
return $u;
}


With this function we are updated our recently created unit into our army or units.

D...function cancel_us

Code: Select all
function cancel_us($id, $type, $res, $weaps, $q)
{
global $db_id;
$town=town($id); $town[7]=explode("-", $town[7]);

$query="update towns set resources='".$res."', weapons='".$weaps."', upkeep=".array_sum($town[7])." where id=".$id;
$result=mysql_query($query, $db_id);
$query="delete from us_queue where town=".$id." and type=".$type;
$result=mysql_query($query, $db_id);
if ($result) echo "<script type='text/javascript'>history.go(-1)</script>";
else msg("Failed.".mysql_error());
}


This is our function to cancel any troops in the queue and update the towns with the weapon and resources not used.

E...function trains

Code: Select all
function trains($a, $id, $type, $q, $time, $res, $weaps)
{
global $db_id;
$town=town($id); $town[7]=explode("-", $town[7]);

$time=explode(":", $time);

if (!$a) $query="select max(dueTime) from us_queue where town=".$id;
else $query="select dueTime from us_queue where town=".$id." and type=".$type;
$result=mysql_query($query, $db_id);
$row=mysql_fetch_row($result);
if ($row[0]!="") $date=strtotime("+".$time[0]." hours ".$time[1]." minutes ".$time[2]." seconds", strtotime($row[0])); else $date=strtotime("+".$time[0]." hours ".$time[1]." minutes ".$time[2]." seconds");
$date=strftime("%Y-%m-%d %H:%M:%S", $date);
if (!$a) $query="insert into us_queue(town, dueTime, type, quantity) values('".$id."', '".$date."', '".$type."', '".$q."')";
else $query="update us_queue set dueTime='".$date."', quantity=quantity+".$q." where town=".$id." and type=".$type;
$result=mysql_query($query, $db_id);
$query="update towns set resources='".$res."', weapons='".$weaps."', upkeep=".(array_sum($town[7])+$q)." where id=".$id;
$result=mysql_query($query, $db_id);
if ($result) echo "<script type='text/javascript'>history.go(-1)</script>";
else msg("Failed.".mysql_error());
}


This our function responsible to do the heavy work to training our Cavalry units.

Now we have created the new function needed for our New training queue , but we need to alter some function in Oder for the engine to know everything about our Queue.

Now in:
function purge
After this line
Code: Select all
mysql_query($query, $db_id);
$query="delete from u_queue where u_queue.town=".$id;


Insert this:
Code: Select all
mysql_query($query, $db_id);
$query="delete from us_queue where us_queue.town=".$id;


This line will be responsible to delete any training queue ( if we have) in our town in case than we want to destroy the town or purge.

Now in:
function check_d
We need to do the same.
So after this line:
Code: Select all
mysql_query($query, $db_id);
   $query="delete from u_queue where u_queue.town in (select id from towns where owner=".$id.")";


Insert this other:

Code: Select all
mysql_query($query, $db_id);
   $query="delete from us_queue where us_queue.town in (select id from towns where owner=".$id.")";


In function del_u
after this line:
Code: Select all
mysql_query($query, $db_id);
   $query="delete from u_queue where u_queue.town in (select id from towns where owner=".$id.")";


Insert this one:
Code: Select all
mysql_query($query, $db_id);
   $query="delete from us_queue where us_queue.town in (select id from towns where owner=".$id.")";


Now we have all the required code and function over function.php to start working on our next part then i explain tomorrow.
Concarster
footman
 
Posts: 114
Joined: Sat Jan 03, 2009 11:42 pm
Location: Knoxville Tn

Re: Different trainQueue and not only One

Postby Concarster » Tue Feb 09, 2010 4:49 am

Well now the next part .
We need to update our barracks.php to recruit only infantry units.
i will put all the code from barracks.php

barracks.php

Code: Select all
<?php
include "antet.php";
include "func.php";
if (isset($_SESSION["user"][0], $_GET["town"])) {
  $towntemp=clean($_GET["town"]);
  check_r($towntemp);
  check_u($towntemp);
  $town=town($towntemp);
  if ($town[1]!=$_SESSION["user"][0]) {
    header('Location: login.php');
    die();
    };
  $faction=faction($_SESSION["user"][10]);
  $r=$faction[3];
  $buildings=buildings($_SESSION["user"][10]);
  $weapons=weapons($_SESSION["user"][10]);
  $c_status=get_con($towntemp);
  $uq=get_u($towntemp);
  $units=units($faction[0]);

  $data=explode("-", $town[8]);
  $res=explode("-", $town[10]);
  $prod=explode("-", $town[9]);
  $lim=explode("-", $town[11]);
  $out=explode("-", $buildings[$bnum][5]);
  $u_upgrades=explode("-", $town[17]);
  $w_upgrades=explode("-", $town[18]);
  $a_upgrades=explode("-", $town[19]);
  $army=explode("-", $town[7]);
  $weaps=explode("-", $town[6]);
  } else {
  header('Location: login.php');
  die();
  };
?>
<head>
<title><?php echo $title." - ".$buildings[15][2]; ?></title>
</head> 
<?php include "scripts/script.php";?>
<body class="q_body" onLoad="startres()">

<div align="center">
<?php include "headerup.php";  ?>
<?php
include "header/header840.tpl";
?>

<table class="q_table">
   <tr>
      <td class="td_content">
<?php      
$bnum=15;

$pagename= $buildings[$bnum][2];
//include "header.php";

if ($data[$bnum]) {
  //include "showres.php";
  echo "<p>".$buildings[$bnum][8]."</p>";
  include "showweap.php";
 
  include "showunits.php";

  if (!$c_status[$bnum]) {
    if ($data[$bnum]<10)  {
      include "showupgrade.php";
     
      } else {
      echo "<p>".$lang['buildingMaxLvl']."</p>";
      };
    } else {
    echo "<p>".$lang['beingUpgraded']."</p>";
    };

  echo "<script language=\"JavaScript\">var A_TPL = {'b_vertical' : false,'b_watch': true,'n_controlWidth': 130,'n_controlHeight': 16,'n_sliderWidth': 16,'n_sliderHeight': 15,'n_pathLeft' : 0,'n_pathTop' : 1,'n_pathLength' : 100,'s_imgControl': 'img/blueh_bg.gif','s_imgSlider': 'img/blueh_sl.gif','n_zIndex': 1};</script>";

  echo "<form name='units' method='post' action='train1.php'>";
  echo "<input type='hidden' name='town' value='".$towntemp."'>";
  echo "<table class=\"q_table\" style=\"border-collapse: collapse; text-indent: 0; margin-left:auto; margin-right:auto;\" width=\"600\" border=\"1\"><tr>";
  echo "<th colspan=\"2\" rowspan=\"2\">".$lang['unitType'];
  echo "</th><th colspan=\"5\">".$lang['cost'];
  echo "</th><th rowspan=\"2\">".$lang['duration'];
  echo "</th><th rowspan=\"2\">".$lang['hp'];
  echo "</th><th rowspan=\"2\">".$lang['atk'];
  echo "</th><th rowspan=\"2\">".$lang['def'];
  echo "</th><th rowspan=\"2\">".$lang['speed'];
  echo "</th><th rowspan=\"2\">".$lang['quantity'];
  echo "</th><th rowspan=\"2\">".$lang['train'];
  echo "</th></tr>";
  echo "<tr><td><img src='".$imgs.$fimgs."00.gif' title='".$lang['crop']."'></td>";
  echo "<td><img src='".$imgs.$fimgs."01.gif' title='".$lang['lumber']."'></td>";
  echo "<td><img src='".$imgs.$fimgs."02.gif' title='".$lang['stone']."'></td>";
  echo "<td><img src='".$imgs.$fimgs."03.gif' title='".$lang['iron']."'></td>";
  echo "<td><img src='".$imgs.$fimgs."04.gif' title='".$lang['gold']."'></td></tr>";

  for ($i=0; $i<count($units); $i++) {
    if (($i<5))  {
      $dur=explode(":", $units[$i][9]);
      $cost=explode("-", $units[$i][4]);
      $req=explode("-", $units[$i][3]);
      echo "<tr><td><img src='".$imgs.$fimgs."2".$i.".gif' width='30' title='".$units[$i][10]."' alt='".$units[$i][10]."'></td>";
      echo "<td>".$units[$i][2]."<br />";
      for ($j=0; $j<count($req); $j++) {
        $afford[]=$weaps[$req[$j]];
        echo "<img src='".$imgs.$fimgs."1".$req[$j].".gif' title='".$weapons[$req[$j]][2]."' alt='".$weapons[$req[$j]][2]."' width=\"20\"'> ";
        };
      echo "</td>";
      for ($j=0; $j<5; $j++) {
        $afford[]=floor($res[$j]/floor($cost[$j]));
        echo "<td>".floor($cost[$j])."</td>";
        };
      sort($afford);
      $totaltime=($dur[0]*60)+$dur[1];
      $newtime=$totaltime*($lim[8]/100);
      $hours= sprintf("%02d",floor($newtime/60));
      $minutes=sprintf("%02d",floor($newtime-($hours*60)));

      echo "<td align=\"center\">".$hours.":".$minutes."</td>";
      echo "<td align=\"center\">".($units[$i][5]+$u_upgrades[$i])."</td>";
      echo "<td align=\"center\">".($units[$i][6]+$w_upgrades[$i])."</td>";
      echo "<td align=\"center\">".($units[$i][7]+$a_upgrades[$i])."</td>";
      echo "<td align=\"center\">".$units[$i][8]."</td>";
      if (($u_upgrades[$i])&&($w_upgrades[$i])&&($a_upgrades[$i])) {
        if ($afford[0]>0) {
          $iname = "q".$i;
          echo "<td><script language=\"JavaScript\">var A_INIT".$i." = {'s_form' : 0,'s_name': '".$iname."','n_minValue' : 0,'n_maxValue' : ".$afford[0].",'n_value' : 0,'n_step' : 1};";
          echo "new slider(A_INIT".$i.", A_TPL);</script>";
          echo "<input class='textbox' name='".$iname."' type='text' size='3' maxlength='3' value='0'> Max: ".$afford[0]."</td>";
          echo "<td><input type='submit' class='button' name='unit' value='".$lang['train']."'></td>";
          } else {
          echo "<td colspan='2'>".$lang['noResources']."</td>";
          }
        echo "</tr>";
        } else {
        echo "<td colspan='2'>".$lang['researchUnit']." ".$lang['in']." ";
        if (!$u_upgrades[$i]) {
          echo $buildings[16][2]."</td></tr>";
          } else {
          if (!$w_upgrades[$i]) {
            echo $buildings[17][2]."</td></tr>";
            } else {
            if (!$a_upgrades[$i]) {
              echo $buildings[17][2]."</td></tr>";
              };
            };
          };
        };
      };
    };
  echo "</table>";
  echo "</form>";

  if (count($uq)) {
    echo "<center><table class='vis'><th align=\"center\">Units Training Queue</th></table>
   <table class='vis'>
<tbody><tr>
<th width='100'>Training</th>
<th width='160'>Units</th>
<th width='120'>Duration</th>
<th width='150'>Completion</th>
<th width='100'>Cancel </th></tr></tbody></table></center>";
    };
  for ($i=0; $i<count($uq); $i++) {
    echo "<center><table class='vis'>
<tbody>   
<tr class='lit'><td width='100'> ".$uq[$i][2]."</td><td width='160'> ".$units[$uq[$i][1]][2]."</td><td width='120'> <span id='".$i."'>".$uq[$i][0]."</span><script type='text/javascript'> var id=new Array(50); timer('".$i."', 'barracks.php?town=".$_GET["town"]."'); </script></td><td width='150'>Completed on:</td><td width='100'><a class='q_link' href='cancel_u.php?town=".$_GET["town"]."&type=".$uq[$i][1]."'>Cancel</a></td></tr>



</tbody></table></center>";
    };
} else {
echo "<p>".$lang['constrBuilding']."</p>";
};


?>
</td>
   </tr>
</table>
<?php include "footer.php";  ?>


If you use your own barracks.php and not this one or the one from curufea version you need to go over line 90 in devana version in this line :

Code: Select all
if (($i<7)||($i>10))


and replace that line with this line:

Code: Select all
if (($i<5))


This liter change give to us the way to recruit only Infantry units in our barracks ,or like in the code the 5 Units than we have in database Sp Sw ESw Bow CrBow .
You don't need to change anything else in barracks.php

Pd... I have modified $uq at the end from this line
Code: Select all
if (count($uq))

to down in a more elegant way to display the Training Que than work with my stile.css so maybe it look different in your game is that the case you need to adapt to your need or replace with original code from your barracks.

Cavalry Units Page
I calling this page brstable.php You can change the name to adapt your need.
This is another page similar to barracks.php but with some litter change to call our function for us_queue and our array $uqs

Code: Select all
<?php include "antet.php"; include "func.php";

if (isset($_SESSION["user"][0], $_GET["town"])) {
  $towntemp=clean($_GET["town"]);
  check_r($towntemp);
  check_u($towntemp);
  check_us($towntemp);
  $town=town($towntemp);
  if ($town[1]!=$_SESSION["user"][0]) {
    header('Location: login.php');
    die();
    };
  $faction=faction($_SESSION["user"][10]);
  $r=$faction[3];
  $buildings=buildings($_SESSION["user"][10]);
  $weapons=weapons($_SESSION["user"][10]);
  $c_status=get_con($towntemp);
  $uq=get_u($towntemp);
  $uqs=get_us($towntemp);
  $units=units($faction[0]);

  $data=explode("-", $town[8]);
  $res=explode("-", $town[10]);
  $prod=explode("-", $town[9]);
  $lim=explode("-", $town[11]);
  $out=explode("-", $buildings[$bnum][5]);
  $u_upgrades=explode("-", $town[17]);
  $w_upgrades=explode("-", $town[18]);
  $a_upgrades=explode("-", $town[19]);
  $army=explode("-", $town[7]);
  $weaps=explode("-", $town[6]);
  } else {
  header('Location: login.php');
  die();
  };
?>
<head>
<title><?php echo $title." - ".$buildings[15][2]; ?></title>
</head> 
<?php include "scripts/script.php";?>
<body class="q_body" onLoad="startres()">

<div align="center">
<?php include "headerup.php";  ?>
<?php
include "header/header840.tpl";
?>

<table class="q_table">
   <tr>
      <td class="td_content">
<?php      
$bnum=15;

$pagename= $buildings[$bnum][2];
//include "header.php";

if ($data[$bnum]) {
  //include "showres.php";
  echo "<p>".$buildings[$bnum][8]."</p>";
  include "showweap.php";
 
  include "showunits.php";

  if (!$c_status[$bnum]) {
    if ($data[$bnum]<10)  {
      include "showupgrade.php";
     
      } else {
      echo "<p>".$lang['buildingMaxLvl']."</p>";
      };
    } else {
    echo "<p>".$lang['beingUpgraded']."</p>";
    };

  echo "<script language=\"JavaScript\">var A_TPL = {'b_vertical' : false,'b_watch': true,'n_controlWidth': 130,'n_controlHeight': 16,'n_sliderWidth': 16,'n_sliderHeight': 15,'n_pathLeft' : 0,'n_pathTop' : 1,'n_pathLength' : 100,'s_imgControl': 'img/blueh_bg.gif','s_imgSlider': 'img/blueh_sl.gif','n_zIndex': 1};</script>";

  echo "<form name='units' method='post' action='trains.php'>";
  echo "<input type='hidden' name='town' value='".$towntemp."'>";
  echo "<table class=\"q_table\" style=\"border-collapse: collapse; text-indent: 0; margin-left:auto; margin-right:auto;\" width=\"600\" border=\"1\"><tr>";
  echo "<th colspan=\"2\" rowspan=\"2\">".$lang['unitType'];
  echo "</th><th colspan=\"5\">".$lang['cost'];
  echo "</th><th rowspan=\"2\">".$lang['duration'];
  echo "</th><th rowspan=\"2\">".$lang['hp'];
  echo "</th><th rowspan=\"2\">".$lang['atk'];
  echo "</th><th rowspan=\"2\">".$lang['def'];
  echo "</th><th rowspan=\"2\">".$lang['speed'];
  echo "</th><th rowspan=\"2\">".$lang['quantity'];
  echo "</th><th rowspan=\"2\">".$lang['train'];
  echo "</th></tr>";
  echo "<tr><td><img src='".$imgs.$fimgs."00.gif' title='".$lang['crop']."'></td>";
  echo "<td><img src='".$imgs.$fimgs."01.gif' title='".$lang['lumber']."'></td>";
  echo "<td><img src='".$imgs.$fimgs."02.gif' title='".$lang['stone']."'></td>";
  echo "<td><img src='".$imgs.$fimgs."03.gif' title='".$lang['iron']."'></td>";
  echo "<td><img src='".$imgs.$fimgs."04.gif' title='".$lang['gold']."'></td></tr>";

  for ($i=5; $i<count($units); $i++) {
    if (($i<7)||($i>10))  {
      $dur=explode(":", $units[$i][9]);
      $cost=explode("-", $units[$i][4]);
      $req=explode("-", $units[$i][3]);
      echo "<tr><td><img src='".$imgs.$fimgs."2".$i.".gif' width='30' title='".$units[$i][10]."' alt='".$units[$i][10]."'></td>";
      echo "<td>".$units[$i][2]."<br />";
      for ($j=0; $j<count($req); $j++) {
        $afford[]=$weaps[$req[$j]];
        echo "<img src='".$imgs.$fimgs."1".$req[$j].".gif' title='".$weapons[$req[$j]][2]."' alt='".$weapons[$req[$j]][2]."' width=\"20\"'> ";
        };
      echo "</td>";
      for ($j=0; $j<5; $j++) {
        $afford[]=floor($res[$j]/floor($cost[$j]));
        echo "<td>".floor($cost[$j])."</td>";
        };
      sort($afford);
      $totaltime=($dur[0]*60)+$dur[1];
      $newtime=$totaltime*($lim[8]/100);
      $hours= sprintf("%02d",floor($newtime/60));
      $minutes=sprintf("%02d",floor($newtime-($hours*60)));

      echo "<td align=\"center\">".$hours.":".$minutes."</td>";
      echo "<td align=\"center\">".($units[$i][5]+$u_upgrades[$i])."</td>";
      echo "<td align=\"center\">".($units[$i][6]+$w_upgrades[$i])."</td>";
      echo "<td align=\"center\">".($units[$i][7]+$a_upgrades[$i])."</td>";
      echo "<td align=\"center\">".$units[$i][8]."</td>";
      if (($u_upgrades[$i])&&($w_upgrades[$i])&&($a_upgrades[$i])) {
        if ($afford[0]>0) {
          $iname = "q".$i;
          echo "<td><script language=\"JavaScript\">var A_INIT".$i." = {'s_form' : 0,'s_name': '".$iname."','n_minValue' : 0,'n_maxValue' : ".$afford[0].",'n_value' : 0,'n_step' : 1};";
          echo "new slider(A_INIT".$i.", A_TPL);</script>";
          echo "<input class='textbox' name='".$iname."' type='text' size='3' maxlength='3' value='0'> Max: ".$afford[0]."</td>";
          echo "<td><input type='submit' class='button' name='unit' value='".$lang['train']."'></td>";
          } else {
          echo "<td colspan='2'>".$lang['noResources']."</td>";
          }
        echo "</tr>";
        } else {
        echo "<td colspan='2'>".$lang['researchUnit']." ".$lang['in']." ";
        if (!$u_upgrades[$i]) {
          echo $buildings[16][2]."</td></tr>";
          } else {
          if (!$w_upgrades[$i]) {
            echo $buildings[17][2]."</td></tr>";
            } else {
            if (!$a_upgrades[$i]) {
              echo $buildings[17][2]."</td></tr>";
              };
            };
          };
        };
      };
    };
  echo "</table>";
  echo "</form>";

  if (count($uqs)) {
    echo "<center><table class='vis'><th align=\"center\">Units Training Queue</th></table>
   <table class='vis'>
<tbody><tr>
<th width='100'>Training</th>
<th width='160'>Units</th>
<th width='120'>Duration</th>
<th width='150'>Completion</th>
<th width='100'>Cancel </th></tr></tbody></table></center>";
    };
  for ($i=0; $i<count($uqs); $i++) {
    echo "<center><table class='vis'>
<tbody>   
<tr class='lit'><td width='100'> ".$uqs[$i][2]."</td><td width='160'> ".$units[$uqs[$i][1]][2]."</td><td width='120'> <span id='".$i."'>".$uqs[$i][0]."</span><script type='text/javascript'> var id=new Array(50); timer('".$i."', 'barracks.php?town=".$_GET["town"]."'); </script></td><td width='150'>Completed on:</td><td width='100'><a class='q_link' href='cancel_us.php?town=".$_GET["town"]."&type=".$uqs[$i][1]."'>Cancel</a></td></tr>



</tbody></table></center>";
    };
} else {
echo "<p>".$lang['constrBuilding']."</p>";
};


?>
</td>
   </tr>
</table>
<?php include "footer.php";  ?>


In this page we change all this :
$uq into $uqs The unitQueue to cavalryQueue than is equal an array from line 154 to line 167
check_us($towntemp); we introduce our function in line 7
$uqs=get_us($towntemp); our Array $uqs with our function get_us on line 19
and finally we change the units than we want to recruit in the brStable on line 98
Last edited by Concarster on Tue Feb 09, 2010 7:14 am, edited 1 time in total.
Concarster
footman
 
Posts: 114
Joined: Sat Jan 03, 2009 11:42 pm
Location: Knoxville Tn

Re: Different trainQueue and not only One

Postby Concarster » Tue Feb 09, 2010 6:49 am

Now is you check brstable.ph you see than we change the page than call our train from train.php tp trains.php

Now we are creating this page using our train.php , we take that page and we rename to trains.php
So here is our page responsible to introduce our cavalry units into our recently created us_queue
Code: Select all
<?php
include "antet.php";
include "func.php";

if (isset($_SESSION["user"][0], $_POST["town"])) {
  foreach ($_POST as $key=>$value) {
    $vars[$key]=abs(clean($value));
    if ((substr($key,0,1)=="q")&&(abs(clean($value))>0)) {
      $typetemp=substr($key,-(strlen($key)-1));
      $qtemp=$vars[$key];
      };
    };
  check_r($vars["town"]);
  $town=town($vars["town"]);
  if ($town[1]!=$_SESSION["user"][0]) {
    header('Location: login.php');
    die();
    };
  $faction=faction($_SESSION["user"][10]);
  $units=units($faction[0]);
  $u_status=get_unss($vars["town"]);
  $weaps=explode("-", $town[6]);
  $res=explode("-", $town[10]);
  $lim=explode("-", $town[11]);
  $u_upgrades=explode("-", $town[17]);
  $w_upgrades=explode("-", $town[18]);
  $a_upgrades=explode("-", $town[19]);

  $l=$lim[8];
  $dur=explode(":", $units[$typetemp][9]);
  $cost=explode("-", $units[$typetemp][4]);
  $req=explode("-", $units[$typetemp][3]);
  $okreq=1;
  if ($req[0]!="") {
    for ($i=0; $i<count($req); $i++) {
      if ($weaps[$req[$i]]<$qtemp) {
        $okreq=0;
        } else {
        $weaps[$req[$i]]-=$qtemp;
        };
      };
    $weaps=implode("-", $weaps);
    };
  if (!$u_status[$typetemp]) {
    $a=0;
    } else {
    $a=1;
    };
  if (($u_upgrades[$typetemp])&&($w_upgrades[$typetemp])&&($a_upgrades[$typetemp])) {
    if ($town[12]+$town[3]+$qtemp<=$lim[3]) {
      if (($res[0]>=$cost[0]*$qtemp)&&($res[1]>=$cost[1]*$qtemp)&&($res[2]>=$cost[2]*$qtemp)&&($res[3]>=$cost[3]*$qtemp)&&($res[4]>=$cost[4]*$qtemp)) {
        if ($okreq) {
          $res[0]-=$cost[0]*$qtemp;
          $res[1]-=$cost[1]*$qtemp;
          $res[2]-=$cost[2]*$qtemp;
          $res[3]-=$cost[3]*$qtemp;
          $res[4]-=$cost[4]*$qtemp;
          $res=implode("-", $res);
          trains($a, $vars["town"], $typetemp, $qtemp, (floor($dur[0]*$qtemp*$l/100)).":".((($dur[0]*$qtemp*$l/100)-floor($dur[0]*$qtemp*$l/100))*60+floor($dur[1]*$qtemp*$l/100)).":".((($dur[1]*$qtemp*$l/100)-floor($dur[1]*$qtemp*$l/100))*60), $res, $weaps);
            } else {
          msg($lang['noItems']);
          };
        } else {
        msg($lang['noResources']);
        };
      } else {
      msg($lang['noHouses']);
      };
    } else {
    msg($lang['researchUnit']." ".$lang['toLevel']." 1.");
    };
  } else {
  header('Location: login.php');
  die();
  };
?>


We introduce:
$u_status=get_unss($vars["town"]); the unit Status with our function get_unss on line 21
And in line 59 we change train to trains to call our function for our cavalry units.

And finally we create the last page so we have a complete new queue for cavalry units and the is cancel_us.php

Code: Select all
<?php include "antet.php"; include "func.php";

if (isset($_SESSION["user"][0], $_GET["town"], $_GET["type"]))
{
$_GET["town"]=clean($_GET["town"]); $_GET["type"]=clean($_GET["type"]);
check_r($_GET["town"]);
$town=town($_GET["town"]); if ($town[1]!=$_SESSION["user"][0]) {header('Location: login.php'); die();}
$uq=get_u($_GET["town"]);
$uqs=get_us($_GET["town"]);
$units=units($_SESSION["user"][10]);

$b=-1; for ($i=0; $i<count($uqs); $i++) if ($uqs[$i][1]==$_GET["type"]) $b=$i;
$res=explode("-", $town[10]); $cost=explode("-", $units[$_GET["type"]][4]); $req=explode("-", $units[$_GET["type"]][3]); $weaps=explode("-", $town[6]);
if ($units[$_GET["type"]][3]) for ($i=0; $i<count($req); $i++) $weaps[$req[$i]]+=$uqs[$b][2];
$weaps=implode("-", $weaps);
$res[0]+=$cost[0]*$uqs[$b][2]; $res[1]+=$cost[1]*$uqs[$b][2]; $res[2]+=$cost[2]*$uqs[$b][2]; $res[3]+=$cost[3]*$uqs[$b][2]; $res[4]+=$cost[4]*$uqs[$b][2]; $res=implode("-", $res);
cancel_us($_GET["town"], $_GET["type"], $res, $weaps, $uqs[$b][2]);
}
else {header('Location: login.php'); die();}
?>


Here we introduce in line 9 our array $uqs with our function get_us
then we change all $uq into $uqs from line 12 to line 17 and finally we call our Function cancel_us at the buiguining of line 17.
Congratulations you now have another Training Queue in you game .
let me know , seeya
Concarster
footman
 
Posts: 114
Joined: Sat Jan 03, 2009 11:42 pm
Location: Knoxville Tn

Re: Different trainQueue and not only One

Postby laura555 » Tue Feb 09, 2010 3:15 pm

Hi, i confused...why you not realize total work and create a zip file and internal tutorial?

Your work is very long.....Is important! But long work!
Sorry, I'am italian girl (EUROPE) and speack little english.....
I and my brother create by devana core, web games italy lang: http://www.travland.it
User avatar
laura555
senior citizen
 
Posts: 667
Joined: Mon Apr 06, 2009 11:09 pm

Re: Different trainQueue and not only One

Postby Concarster » Tue Feb 09, 2010 7:28 pm

Time laura , but let me see what can i do.
Concarster
footman
 
Posts: 114
Joined: Sat Jan 03, 2009 11:42 pm
Location: Knoxville Tn

Re: Different trainQueue and not only One

Postby laura555 » Wed Feb 10, 2010 2:27 am

Concarster wrote:Time laura , but let me see what can i do.

ok ok, stanby...because in devana original, this mod dont work and in travland dont work.

My barracks.php is different and use curufea mod and, my now implementation not use weapons:
I want your mod but want use my graphics
my barracks.php
Code: Select all
<?php include "antet.php"; include "func.php";
?>

<script language="JavaScript">

function nothing()
{}
</script>

<?
if (isset($_SESSION["user"][0], $_GET["town"]))
{
$_GET["town"]=clean($_GET["town"]);
check_r($_GET["town"]);
check_u($_GET["town"]);
$town=town($_GET["town"]); if ($town[1]!=$_SESSION["user"][0]) {header('Location: login.php'); die();}
$faction=faction($_SESSION["user"][10]); $r=$faction[3];
$buildings=buildings($_SESSION["user"][10]);
$weapons=weapons($_SESSION["user"][10]);
$c_status=get_con($_GET["town"]);
$uq=get_u($_GET["town"]);
$units=units($faction[0]);

$data=explode("-", $town[8]); $res=explode("-", $town[10]); $prod=explode("-", $town[9]); $lim=explode("-", $town[11]); $out=explode("-", $buildings[15][5]); $u_upgrades=explode("-", $town[17]); $w_upgrades=explode("-", $town[18]); $a_upgrades=explode("-", $town[19]); $army=explode("-", $town[7]); $weaps=explode("-", $town[6]);
}
else {header('Location: login.php'); die();}
?>
<html>
<?php echo "<link rel='stylesheet' type='text/css' href='".$imgs.$fimgs."default.css'>"; ?>
<script src="func.js" type="text/javascript"></script>
<script type="text/javascript">
var res_start0=<?php echo floor($res[0]);?>; var res_start1=<?php echo floor($res[1]);?>; var res_start2=<?php echo floor($res[2]);?>; var res_start3=<?php echo floor($res[3]);?>; var res_start4=<?php echo floor($res[4]);?>;
var res_limit0=<?php echo $lim[0];?>; var res_limit1=<?php echo $lim[1];?>; var res_limit2=<?php echo $lim[1];?>; var res_limit3=<?php echo $lim[1];?>; var res_limit4=<?php echo $lim[2];?>;
var res_ph0=<?php echo ($prod[0]-$town[3]-$town[12]);?>; var res_ph1=<?php echo ($prod[1]);?>; var res_ph2=<?php echo ($prod[2]);?>; var res_ph3=<?php echo ($prod[3]);?>; var res_ph4=<?php echo ($prod[4]);?>;
var res_sec0=0; var res_sec1=0; var res_sec2=0; var res_sec3=0; var res_sec4=0;
</script>

<head>
<title><?php echo $title." - ".$buildings[15][2]; ?></title>
</head>

<body class="q_body" onLoad="startres()">

<div align="center">
<?php echo $top_ad; ?>

<table class="q_table">
   <tr>
      <td class="td_logo">
      <?php logo($title); ?></td>
   </tr>
   <tr>
      <td class="td_top_menu"><?php menu_up(); ?></td>
   </tr>
   <tr>
      <td class="td_content">
      <center>
      <img src='addestramento.jpg' height='240'>
      </center>
          <p>
<?php
if ($data[15])
{
echo "<img src='".$imgs.$fimgs."00.gif' title='".$lang['crop']."'><span id=\"res0\"></span>/".$lim[0]." <img src='".$imgs.$fimgs."01.gif' title='".$lang['lumber']."'><span id=\"res1\"></span>/".$lim[1]." <img src='".$imgs.$fimgs."02.gif' title='".$lang['stone']."'><span id=\"res2\"></span>/".$lim[1]." <img src='".$imgs.$fimgs."03.gif' title='".$lang['iron']."'><span id=\"res3\"></span>/".$lim[1]." <img src='".$imgs.$fimgs."04.gif' title='".$lang['gold']."'><span id=\"res4\"></span>/".$lim[2]."</br></br>";
echo $buildings[15][8]."</br></br>";
//echo $lang['currentStorCap'].": ".$lim[12]." ".$lang['type']."</br>";
echo "------------------------------------------</br>";
echo $lang['availableTroops'].":<table class='q_table' style='border-collapse: collapse; text-indent: 0; text-align: center' width='600' border='1'><tr>";
for ($i=0; $i<count($units); $i++) echo "<td><img src='".$imgs.$fimgs."2".$i.".gif' height='29' title='".$units[$i][2]."'></td>";
echo "</tr><tr>";
for ($i=0; $i<count($army); $i++) echo "<td>".$army[$i]."</td>";
echo "</tr></table>------------------------------------------</br>";
if (!$c_status[15])
    if ($data[15]<10)
      {
       $dur=explode("-", $buildings[15][6]); $upk=explode("-", $buildings[15][7]); $cost=explode("-", $buildings[15][4]); $dur[$data[15]]=explode(":", $dur[$data[15]]);
       $tag="<a class='q_link' href='build.php?town=".$town[0]."&b=".$buildings[15][0]."&subB=-1'>".$lang['upgrade']." ".$buildings[15][2]." ".$lang['toLevel']." ".($data[15]+1)."</a>";
       $tag=$tag."</br>".$lang['cost'].": <img src='".$imgs.$fimgs."00.gif' title='".$lang['crop']."'>".floor($cost[0]*pow($r, $data[15]))." <img src='".$imgs.$fimgs."01.gif' title='".$lang['lumber']."'>".floor($cost[1]*pow($r, $data[15]))." <img src='".$imgs.$fimgs."02.gif' title='".$lang['stone']."'>".floor($cost[2]*pow($r, $data[15]))." <img src='".$imgs.$fimgs."03.gif' title='".$lang['iron']."'>".floor($cost[3]*pow($r, $data[15]))." <img src='".$imgs.$fimgs."04.gif' title='".$lang['gold']."'>".floor($cost[4]*pow($r, $data[15]))."</br>".$lang['duration'].": ".($dur[$data[15]][0]*$lim[4]/100).":".($dur[$data[15]][1]*$lim[4]/100)."</br>".$lang['upkeep'].": ".$upk[$data[15]]."</br>".$lang['expSpeed'].": ".$out[$data[15]];
       echo $tag;
       if ($town[12]+$town[3]+$upk[$data[15]]>$lim[3]) label("</br>".$lang['noHouses']);
       if (!(($res[0]>=$cost[0]*pow($r, $data[15]))&&($res[1]>=$cost[1]*pow($r, $data[15]))&&($res[2]>=$cost[2]*pow($r, $data[15]))&&($res[3]>=$cost[3]*pow($r, $data[15]))&&($res[4]>=$cost[4]*pow($r, $data[15])))) label("</br>".$lang['noResources']);
       echo "</br>------------------------------------------</br>";
      }
    else echo $lang['buildingMaxLvl'];
else echo $lang['beingUpgraded'];
}
else echo $lang['constrBuilding'];
?>
       <table class="q_table" style="border-collapse: collapse; text-indent: 0; margin-left:auto; margin-right:auto;" width="600" border="1">
            <tr style='text-align: center'>
              <td><?php echo $lang['unitType'] ?></td>
              <td><?php echo $lang['quantity'] ?></td>
              <td><?php echo $lang['train'] ?></td>
            </tr>
<?php

if ($data[15])
for ($i=0; $i<count($units); $i++)
if (($i<5)||($i>10))
{
//determine max value that can be produced
$Res_Ind = array();
$Res_Ind = explode("-",$units[$i][4]);

for($r=0; $r<5; $r++)
{
  $Res_Ind[] = $res[$r];
}

$w_cap = $lim[12]*100;// ho aggiunto *100 perché non c'é limite di forgiatura armi nello stoccaggio
$w_cap -= $unit[$i];

//$max1 = Max_Prod($Res_Ind[0],$Res_Ind[1],$Res_Ind[2],$Res_Ind[3],$Res_Ind[4],$Res_Ind[5],$Res_Ind[6],$Res_Ind[7],$Res_Ind[8],$Res_Ind[9],$w_cap);

$weaps= array();
$weaps=explode("-", $town[6]);

//if($units[$i][3]=$units[0][3])$w[0]= floor(min($weaps[0],$weaps[6]));
//if($units[$i][3]=$units[1][3])$w[1]= floor(min($weaps[1],$weaps[6],$weaps[8]));
//if($units[$i][3]=$units[2][3])$w[2]= floor(min($weaps[2],$weaps[7],$weaps[8]));
//if($units[$i][3]=$units[3][3])$w[3]= floor(min($weaps[3],$weaps[5]));
//if($units[$i][3]=$units[4][3])$w[4]= floor(min($weaps[4],$weaps[6]));
//if($units[$i][3]=$units[5][3])$w[5]= floor(min($weaps[2],$weaps[7],$weaps[8],$weaps[9]));
//if($units[$i][3]=$units[6][3])$w[6]= floor(min($weaps[3],$weaps[5],$weaps[9]));
//if($units[$i][3]=$units[11][3])$w[11]= floor(min($weaps[1],$weaps[5]));
//if($units[$i][3]=$units[12][3])$w[12]= floor(min($weaps[1],$weaps[5],$weaps[9]));
//else
//($w[$i]= $max1);

//$max =floor(min($max1,$w[$i]));
$max = Max_Prod($Res_Ind[0],$Res_Ind[1],$Res_Ind[2],$Res_Ind[3],$Res_Ind[4],$Res_Ind[5],$Res_Ind[6],$Res_Ind[7],$Res_Ind[8],$Res_Ind[9],$w_cap);
//determine max value that can be produced
  $dur=explode(":", $units[$i][9]); $cost=explode("-", $units[$i][4]);
  if (($u_upgrades[$i])&&($w_upgrades[$i])&&($a_upgrades[$i])) echo "<form name='units_".str_replace(" ","",$units[$i][2])."' method='post' action='train.php?town=".$_GET["town"]."&type=".$i."'><tr style='text-align: center;'><td><img src='".$imgs.$fimgs."2".$i.".gif' height='29' title='".$units[$i][2]."'></br>".$units[$i][10]."</br>".$lang['cost'].": <img src='".$imgs.$fimgs."00.gif' title='".$lang['crop']."'>".floor($cost[0])." <img src='".$imgs.$fimgs."01.gif' title='".$lang['lumber']."'>".floor($cost[1])." <img src='".$imgs.$fimgs."02.gif' title='".$lang['stone']."'>".floor($cost[2])." <img src='".$imgs.$fimgs."03.gif' title='".$lang['iron']."'>".floor($cost[3])." <img src='".$imgs.$fimgs."04.gif' title='".$lang['gold']."'>".floor($cost[4])."</br>".$lang['duration'].": ".($dur[0]*$lim[8]/100).":".($dur[1]*$lim[8]/100).", ".$lang['hp'].": ".($units[$i][5]+$u_upgrades[$i]).", ".$lang['atk'].": ".($units[$i][6]+$w_upgrades[$i]).", ".$lang['def'].": ".($units[$i][7]+$a_upgrades[$i]).", ".$lang['speed'].": ".$units[$i][8].".</td><td><input class='textbox' name='q' type='text' size='3' maxlength='3' value='0'><a class='q_link_3' href=\"Javascript:nothing()\" onClick=\"document.units_".str_replace(" ","",$units[$i][2]).".q.value='$max'\">   max $max</a></td><td><input type='submit' class='button' name='unit_' value='".$lang['train']."'></td></tr></form>";
  else echo "<tr style='text-align: center;'><td><img src='".$imgs.$fimgs."2".$i.".gif' height='29' title='".$units[$i][2]."'></br>".$units[$i][10]."</td><td colspan='2'>".$lang['researchUnit']." ".$lang['in']." ";
  if (!$u_upgrades[$i]) echo $buildings[16][2]."</td></tr>";
  else if (!$w_upgrades[$i]) echo $buildings[18][2]."</td></tr>";
  else if (!$a_upgrades[$i]) echo $buildings[17][2]."</td></tr>";
}
echo "</table>";
if (count($uq)) echo $lang['trainQueue'].":</br>";
for ($i=0; $i<count($uq); $i++) echo "[<a class='q_link' href='cancel_u.php?town=".$_GET["town"]."&type=".$uq[$i][1]."'>x</a>] ".$uq[$i][2]." ".$units[$uq[$i][1]][2]." - <span id='".$i."'>".$uq[$i][0]."</span><script type='text/javascript'> var id=new Array(50); timer('".$i."', 'barracks.php?town=".$_GET["town"]."'); </script></br>";
?>
          </p>
     </td>
   </tr>
   <tr>
      <td class="td_bottom_menu">
      <?php menu_down(); ?></td>
   </tr>
</table>

<?php echo $bottom_ad; ?>
<p><?php about(); ?></div>

</body>

</html>


remember...in your barracks php you linked trainin train1.php and not trains.php
i have fix but dont work...return login page....sorry
:shock:
Sorry, I'am italian girl (EUROPE) and speack little english.....
I and my brother create by devana core, web games italy lang: http://www.travland.it
User avatar
laura555
senior citizen
 
Posts: 667
Joined: Mon Apr 06, 2009 11:09 pm

Re: Different trainQueue and not only One

Postby Concarster » Wed Feb 10, 2010 4:03 am

laura train1.php is the normal train than coming with curufea version with devana is train.php your barracks work ok , i checked ,
Go to line 95 in your barracks.php

Code: Select all
for ($i=0; $i<count($units); $i++)
if (($i<5)||($i>10))


In there change line 96
Code: Select all
if (($i<5)||($i>10))
replace with this
Code: Select all
if (($i<5))
in other world we are calling here only the first 5 units from 0 to 4 on the barracks .
Now you don't need to change anything else in barracks.php , keep all as you have
in your game.Check that an let me know

I put my code for barracks.php so every one can check what i did , and have a better idea about what i did.

Oops i forguet trains.php is the train than we call with brstable.php is appart from barracks
Concarster
footman
 
Posts: 114
Joined: Sat Jan 03, 2009 11:42 pm
Location: Knoxville Tn

Re: Different trainQueue and not only One

Postby Concarster » Wed Feb 10, 2010 6:46 am

Laura this is your page for Cavalry.
barrackslaura.php

Code: Select all
<?php include "antet.php"; include "func.php";
?>

<script language="JavaScript">

function nothing()
{}
</script>

<?
if (isset($_SESSION["user"][0], $_GET["town"]))
{
$_GET["town"]=clean($_GET["town"]);
check_r($_GET["town"]);
check_u($_GET["town"]);
check_us($_GET["town"]);
$town=town($_GET["town"]); if ($town[1]!=$_SESSION["user"][0]) {header('Location: login.php'); die();}
$faction=faction($_SESSION["user"][10]); $r=$faction[3];
$buildings=buildings($_SESSION["user"][10]);
$weapons=weapons($_SESSION["user"][10]);
$c_status=get_con($_GET["town"]);
$uq=get_u($_GET["town"]);
$uqs=get_us($_GET["town"]);
$units=units($faction[0]);

$data=explode("-", $town[8]); $res=explode("-", $town[10]); $prod=explode("-", $town[9]); $lim=explode("-", $town[11]); $out=explode("-", $buildings[15][5]); $u_upgrades=explode("-", $town[17]); $w_upgrades=explode("-", $town[18]); $a_upgrades=explode("-", $town[19]); $army=explode("-", $town[7]); $weaps=explode("-", $town[6]);
}
else {header('Location: login.php'); die();}
?>
<html>
<?php echo "<link rel='stylesheet' type='text/css' href='".$imgs.$fimgs."default.css'>"; ?>
<script src="func.js" type="text/javascript"></script>
<script type="text/javascript">
var res_start0=<?php echo floor($res[0]);?>; var res_start1=<?php echo floor($res[1]);?>; var res_start2=<?php echo floor($res[2]);?>; var res_start3=<?php echo floor($res[3]);?>; var res_start4=<?php echo floor($res[4]);?>;
var res_limit0=<?php echo $lim[0];?>; var res_limit1=<?php echo $lim[1];?>; var res_limit2=<?php echo $lim[1];?>; var res_limit3=<?php echo $lim[1];?>; var res_limit4=<?php echo $lim[2];?>;
var res_ph0=<?php echo ($prod[0]-$town[3]-$town[12]);?>; var res_ph1=<?php echo ($prod[1]);?>; var res_ph2=<?php echo ($prod[2]);?>; var res_ph3=<?php echo ($prod[3]);?>; var res_ph4=<?php echo ($prod[4]);?>;
var res_sec0=0; var res_sec1=0; var res_sec2=0; var res_sec3=0; var res_sec4=0;
</script>

<head>
<title><?php echo $title." - ".$buildings[15][2]; ?></title>
</head>

<body class="q_body" onLoad="startres()">

<div align="center">
<?php echo $top_ad; ?>

<table class="q_table">
   <tr>
      <td class="td_logo">
      <?php logo($title); ?></td>
   </tr>
   <tr>
      <td class="td_top_menu"><?php menu_up(); ?></td>
   </tr>
   <tr>
      <td class="td_content">
      <center>
      <img src='addestramento.jpg' height='240'>
      </center>
          <p>
<?php
if ($data[15])
{
echo "<img src='".$imgs.$fimgs."00.gif' title='".$lang['crop']."'><span id=\"res0\"></span>/".$lim[0]." <img src='".$imgs.$fimgs."01.gif' title='".$lang['lumber']."'><span id=\"res1\"></span>/".$lim[1]." <img src='".$imgs.$fimgs."02.gif' title='".$lang['stone']."'><span id=\"res2\"></span>/".$lim[1]." <img src='".$imgs.$fimgs."03.gif' title='".$lang['iron']."'><span id=\"res3\"></span>/".$lim[1]." <img src='".$imgs.$fimgs."04.gif' title='".$lang['gold']."'><span id=\"res4\"></span>/".$lim[2]."</br></br>";
echo $buildings[15][8]."</br></br>";
//echo $lang['currentStorCap'].": ".$lim[12]." ".$lang['type']."</br>";
echo "------------------------------------------</br>";
echo $lang['availableTroops'].":<table class='q_table' style='border-collapse: collapse; text-indent: 0; text-align: center' width='600' border='1'><tr>";
for ($i=0; $i<count($units); $i++) echo "<td><img src='".$imgs.$fimgs."2".$i.".gif' height='29' title='".$units[$i][2]."'></td>";
echo "</tr><tr>";
for ($i=0; $i<count($army); $i++) echo "<td>".$army[$i]."</td>";
echo "</tr></table>------------------------------------------</br>";
if (!$c_status[15])
    if ($data[15]<10)
      {
       $dur=explode("-", $buildings[15][6]); $upk=explode("-", $buildings[15][7]); $cost=explode("-", $buildings[15][4]); $dur[$data[15]]=explode(":", $dur[$data[15]]);
       $tag="<a class='q_link' href='build.php?town=".$town[0]."&b=".$buildings[15][0]."&subB=-1'>".$lang['upgrade']." ".$buildings[15][2]." ".$lang['toLevel']." ".($data[15]+1)."</a>";
       $tag=$tag."</br>".$lang['cost'].": <img src='".$imgs.$fimgs."00.gif' title='".$lang['crop']."'>".floor($cost[0]*pow($r, $data[15]))." <img src='".$imgs.$fimgs."01.gif' title='".$lang['lumber']."'>".floor($cost[1]*pow($r, $data[15]))." <img src='".$imgs.$fimgs."02.gif' title='".$lang['stone']."'>".floor($cost[2]*pow($r, $data[15]))." <img src='".$imgs.$fimgs."03.gif' title='".$lang['iron']."'>".floor($cost[3]*pow($r, $data[15]))." <img src='".$imgs.$fimgs."04.gif' title='".$lang['gold']."'>".floor($cost[4]*pow($r, $data[15]))."</br>".$lang['duration'].": ".($dur[$data[15]][0]*$lim[4]/100).":".($dur[$data[15]][1]*$lim[4]/100)."</br>".$lang['upkeep'].": ".$upk[$data[15]]."</br>".$lang['expSpeed'].": ".$out[$data[15]];
       echo $tag;
       if ($town[12]+$town[3]+$upk[$data[15]]>$lim[3]) label("</br>".$lang['noHouses']);
       if (!(($res[0]>=$cost[0]*pow($r, $data[15]))&&($res[1]>=$cost[1]*pow($r, $data[15]))&&($res[2]>=$cost[2]*pow($r, $data[15]))&&($res[3]>=$cost[3]*pow($r, $data[15]))&&($res[4]>=$cost[4]*pow($r, $data[15])))) label("</br>".$lang['noResources']);
       echo "</br>------------------------------------------</br>";
      }
    else echo $lang['buildingMaxLvl'];
else echo $lang['beingUpgraded'];
}
else echo $lang['constrBuilding'];
?>
       <table class="q_table" style="border-collapse: collapse; text-indent: 0; margin-left:auto; margin-right:auto;" width="600" border="1">
            <tr style='text-align: center'>
              <td><?php echo $lang['unitType'] ?></td>
              <td><?php echo $lang['quantity'] ?></td>
              <td><?php echo $lang['train'] ?></td>
            </tr>
<?php

if ($data[15])
for ($i=5; $i<count($units); $i++)
if (($i<7)||($i>10))
{
//determine max value that can be produced
$Res_Ind = array();
$Res_Ind = explode("-",$units[$i][4]);

for($r=0; $r<5; $r++)
{
  $Res_Ind[] = $res[$r];
}

$w_cap = $lim[12]*100;// ho aggiunto *100 perché non c'é limite di forgiatura armi nello stoccaggio
$w_cap -= $unit[$i];

//$max1 = Max_Prod($Res_Ind[0],$Res_Ind[1],$Res_Ind[2],$Res_Ind[3],$Res_Ind[4],$Res_Ind[5],$Res_Ind[6],$Res_Ind[7],$Res_Ind[8],$Res_Ind[9],$w_cap);

$weaps= array();
$weaps=explode("-", $town[6]);

//if($units[$i][3]=$units[0][3])$w[0]= floor(min($weaps[0],$weaps[6]));
//if($units[$i][3]=$units[1][3])$w[1]= floor(min($weaps[1],$weaps[6],$weaps[8]));
//if($units[$i][3]=$units[2][3])$w[2]= floor(min($weaps[2],$weaps[7],$weaps[8]));
//if($units[$i][3]=$units[3][3])$w[3]= floor(min($weaps[3],$weaps[5]));
//if($units[$i][3]=$units[4][3])$w[4]= floor(min($weaps[4],$weaps[6]));
//if($units[$i][3]=$units[5][3])$w[5]= floor(min($weaps[2],$weaps[7],$weaps[8],$weaps[9]));
//if($units[$i][3]=$units[6][3])$w[6]= floor(min($weaps[3],$weaps[5],$weaps[9]));
//if($units[$i][3]=$units[11][3])$w[11]= floor(min($weaps[1],$weaps[5]));
//if($units[$i][3]=$units[12][3])$w[12]= floor(min($weaps[1],$weaps[5],$weaps[9]));
//else
//($w[$i]= $max1);

//$max =floor(min($max1,$w[$i]));
$max = Max_Prod($Res_Ind[0],$Res_Ind[1],$Res_Ind[2],$Res_Ind[3],$Res_Ind[4],$Res_Ind[5],$Res_Ind[6],$Res_Ind[7],$Res_Ind[8],$Res_Ind[9],$w_cap);
//determine max value that can be produced
  $dur=explode(":", $units[$i][9]); $cost=explode("-", $units[$i][4]);
  if (($u_upgrades[$i])&&($w_upgrades[$i])&&($a_upgrades[$i])) echo "<form name='units_".str_replace(" ","",$units[$i][2])."' method='post' action='trainlaura.php?town=".$_GET["town"]."&type=".$i."'><tr style='text-align: center;'><td><img src='".$imgs.$fimgs."2".$i.".gif' height='29' title='".$units[$i][2]."'></br>".$units[$i][10]."</br>".$lang['cost'].": <img src='".$imgs.$fimgs."00.gif' title='".$lang['crop']."'>".floor($cost[0])." <img src='".$imgs.$fimgs."01.gif' title='".$lang['lumber']."'>".floor($cost[1])." <img src='".$imgs.$fimgs."02.gif' title='".$lang['stone']."'>".floor($cost[2])." <img src='".$imgs.$fimgs."03.gif' title='".$lang['iron']."'>".floor($cost[3])." <img src='".$imgs.$fimgs."04.gif' title='".$lang['gold']."'>".floor($cost[4])."</br>".$lang['duration'].": ".($dur[0]*$lim[8]/100).":".($dur[1]*$lim[8]/100).", ".$lang['hp'].": ".($units[$i][5]+$u_upgrades[$i]).", ".$lang['atk'].": ".($units[$i][6]+$w_upgrades[$i]).", ".$lang['def'].": ".($units[$i][7]+$a_upgrades[$i]).", ".$lang['speed'].": ".$units[$i][8].".</td><td><input class='textbox' name='q' type='text' size='3' maxlength='3' value='0'><a class='q_link_3' href=\"Javascript:nothing()\" onClick=\"document.units_".str_replace(" ","",$units[$i][2]).".q.value='$max'\">   max $max</a></td><td><input type='submit' class='button' name='unit_' value='".$lang['train']."'></td></tr></form>";
  else echo "<tr style='text-align: center;'><td><img src='".$imgs.$fimgs."2".$i.".gif' height='29' title='".$units[$i][2]."'></br>".$units[$i][10]."</td><td colspan='2'>".$lang['researchUnit']." ".$lang['in']." ";
  if (!$u_upgrades[$i]) echo $buildings[16][2]."</td></tr>";
  else if (!$w_upgrades[$i]) echo $buildings[18][2]."</td></tr>";
  else if (!$a_upgrades[$i]) echo $buildings[17][2]."</td></tr>";
}
echo "</table>";
if (count($uqs)) echo $lang['trainQueue'].":</br>";
for ($i=0; $i<count($uqs); $i++) echo "[<a class='q_link' href='cancel_us.php?town=".$_GET["town"]."&type=".$uqs[$i][1]."'>x</a>] ".$uqs[$i][2]." ".$units[$uqs[$i][1]][2]." - <span id='".$i."'>".$uqs[$i][0]."</span><script type='text/javascript'> var id=new Array(50); timer('".$i."', 'barrackslaura.php?town=".$_GET["town"]."'); </script></br>";
?>
          </p>
     </td>
   </tr>
   <tr>
      <td class="td_bottom_menu">
      <?php menu_down(); ?></td>
   </tr>
</table>

<?php echo $bottom_ad; ?>
<p><?php about(); ?></div>

</body>

</html>


Put this function over func.php

Code: Select all
function get_unslaura($id)
{
global $db_id;

$query="select type from us_queue where town=".$id;
$result=mysql_query($query, $db_id);
$u=array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
for ($i=0; $row=mysql_fetch_row($result); $i++) $u[$row[0]]=1;
return $u;
}


now use this page as your train call

trainlaura.php

Code: Select all
<?php include "antet.php"; include "func.php";

if (isset($_SESSION["user"][0], $_GET["town"], $_GET["type"], $_POST["q"]))
{
$_GET["town"]=clean($_GET["town"]); $_GET["type"]=clean($_GET["type"]); $_POST["q"]=clean($_POST["q"]);
$_POST["q"]=abs($_POST["q"]);//anti cheat
check_r($_GET["town"]);
$town=town($_GET["town"]); if ($town[1]!=$_SESSION["user"][0]) {header('Location: login.php'); die();}
$faction=faction($_SESSION["user"][10]);
$units=units($faction[0]);
$u_status=get_unslaura($_GET["town"]);
$weaps=explode("-", $town[6]); $res=explode("-", $town[10]); $lim=explode("-", $town[11]); $u_upgrades=explode("-", $town[17]); $w_upgrades=explode("-", $town[18]); $a_upgrades=explode("-", $town[19]);

$l=$lim[8]; $dur=explode(":", $units[$_GET["type"]][9]); $cost=explode("-", $units[$_GET["type"]][4]); $req=explode("-", $units[$_GET["type"]][3]);
$okreq=1; if ($req[0]!="") for ($i=0; $i<count($req); $i++) if ($weaps[$req[$i]]<$_POST["q"]) $okreq=0; else $weaps[$req[$i]]-=$_POST["q"]; $weaps=implode("-", $weaps);
if (!$u_status[$_GET["type"]]) $a=0; else $a=1;
if (($u_upgrades[$_GET["type"]])&&($w_upgrades[$_GET["type"]])&&($a_upgrades[$_GET["type"]]))
  if ($town[12]+$town[3]+$_POST["q"]<=$lim[3])
   if (($res[0]>=$cost[0]*$_POST["q"])&&($res[1]>=$cost[1]*$_POST["q"])&&($res[2]>=$cost[2]*$_POST["q"])&&($res[3]>=$cost[3]*$_POST["q"])&&($res[4]>=$cost[4]*$_POST["q"]))
    if ($okreq)
    {
     $res[0]-=$cost[0]*$_POST["q"]; $res[1]-=$cost[1]*$_POST["q"]; $res[2]-=$cost[2]*$_POST["q"]; $res[3]-=$cost[3]*$_POST["q"]; $res[4]-=$cost[4]*$_POST["q"]; $res=implode("-", $res);
     trains($a, $_GET["town"], $_GET["type"], abs($_POST["q"]), (floor($dur[0]*$_POST["q"]*$l/100)).":".((($dur[0]*$_POST["q"]*$l/100)-floor($dur[0]*$_POST["q"]*$l/100))*60+floor($dur[1]*$_POST["q"]*$l/100)).":".((($dur[1]*$_POST["q"]*$l/100)-floor($dur[1]*$_POST["q"]*$l/100))*60), $res, $weaps);
    }
    else msg($lang['noItems']);
   else msg($lang['noResources']);
  else msg($lang['noHouses']);
else msg($lang['researchUnit']." ".$lang['toLevel']." 1.");
}
else {header('Location: login.php'); die();}
?>


Let me know
Concarster
footman
 
Posts: 114
Joined: Sat Jan 03, 2009 11:42 pm
Location: Knoxville Tn

Re: Different trainQueue and not only One

Postby laura555 » Wed Feb 10, 2010 4:13 pm

Hahahahaha....thanks for name laura in pages php...i try....
Sorry, I'am italian girl (EUROPE) and speack little english.....
I and my brother create by devana core, web games italy lang: http://www.travland.it
User avatar
laura555
senior citizen
 
Posts: 667
Joined: Mon Apr 06, 2009 11:09 pm

Re: Different trainQueue and not only One

Postby laura555 » Wed Feb 10, 2010 8:43 pm

WAO!
My compliments!
Very work and Excellent idea!
I want implemented in sshop.php this system!

Good!

You work sshop.php in future?

I have implemented new system travland exclusion weapons!
and
In barracks.php infantry troops
in stable.php cavalry troops
is sshop.php damage army
in port.php the navy battle
This troops not required weapons
my website test:
www.travland.it/s2
This is functionally and implemented scout for use spy (system navy battle)
battle scout attaccker for scout defender
Is tactical land system for spy other villages
Sorry, I'am italian girl (EUROPE) and speack little english.....
I and my brother create by devana core, web games italy lang: http://www.travland.it
User avatar
laura555
senior citizen
 
Posts: 667
Joined: Mon Apr 06, 2009 11:09 pm

Re: Different trainQueue and not only One

Postby Concarster » Thu Feb 11, 2010 10:57 pm

I have implemented all this in my game .
1... for Barracks =u_queue this the normal trainQueue for devana than in
my game it only recruit now foot troops or ( Spearman
,Swordsman ,Elite Swordsman, Bowman and Crossbowman)
2... for Stable=us_queue this recruit only cavalry units ( Knight, Ranger
,Scout ,Colonist)
3... For Port =uvote_queue this recruit only vote (Warship ,Transport ship)
4... For Sshop=ubat_queue this recruit only (Battering ram, Catapult)

All of those are working now.

I explain the us_queue for cavalry cause after that if any one follow the instruction is not too bad and you
can make your own queue for your own stile game.

As this is a long work and you need to modify many function over the func.php and create more function , i was thinking about was laura talk me .
So i want to do this as an independent module with all the function in a separate function apart from func.php using and include call , this way , we don't need to rewrite everything again , every time than the engine upgrade to new version.

i thing is the best way.
Concarster
footman
 
Posts: 114
Joined: Sat Jan 03, 2009 11:42 pm
Location: Knoxville Tn

Re: Different trainQueue and not only One

Postby laura555 » Fri Feb 12, 2010 2:08 am

Concarster wrote:I have implemented all this in my game .
1... for Barracks =u_queue this the normal trainQueue for devana than in
my game it only recruit now foot troops or ( Spearman
,Swordsman ,Elite Swordsman, Bowman and Crossbowman)
2... for Stable=us_queue this recruit only cavalry units ( Knight, Ranger
,Scout ,Colonist)
3... For Port =uvote_queue this recruit only vote (Warship ,Transport ship)
4... For Sshop=ubat_queue this recruit only (Battering ram, Catapult)

All of those are working now.

I explain the us_queue for cavalry cause after that if any one follow the instruction is not too bad and you
can make your own queue for your own stile game.

As this is a long work and you need to modify many function over the func.php and create more function , i was thinking about was laura talk me .
So i want to do this as an independent module with all the function in a separate function apart from func.php using and include call , this way , we don't need to rewrite everything again , every time than the engine upgrade to new version.

i thing is the best way.

in your post is riferiment copy for all works...
i worked...thanks
Sorry, I'am italian girl (EUROPE) and speack little english.....
I and my brother create by devana core, web games italy lang: http://www.travland.it
User avatar
laura555
senior citizen
 
Posts: 667
Joined: Mon Apr 06, 2009 11:09 pm


Return to Mods

Who is online

Users browsing this forum: No registered users and 2 guests