• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

MyAAC Gesior

Gubailovo

Member
Joined
Dec 19, 2013
Messages
199
Solutions
1
Reaction score
17
help with the table of monsters please.
I want the "Summonable Mana" column to display the monster image, and the "Convinceable Mana" column to display the loot image.
Скриншот 02-03-2021 094434.jpg
Скриншот 02-03-2021 094538.jpg
PHP:
<?php
/**
 * Creatures
 *
 * @package   MyAAC
 * @author    Gesior <[email protected]>
 * @author    Slawkens <[email protected]>
 * @copyright 2019 MyAAC
 * @link      https://my-aac.org
 */
defined('MYAAC') or die('Direct access not allowed!');
$title = "Creatures";

?>
<script type="text/javascript" src="tools/js/tipped.js"></script>
<link rel="stylesheet" type="text/css" href="tools/css/tipped.css"/>
<link rel="stylesheet" href="<?php echo BASE_URL; ?>tools/css/jquery.dataTables.min.css">

<script>
    $(document).ready(function () {
        Tipped.create('.item_image');
    });
</script>

<?php
$canEdit = hasFlag(FLAG_CONTENT_MONSTERS) || admin();
if (isset($_POST['reload_monsters']) && $canEdit) {
    require LIBS . 'creatures.php';
    if (Creatures::loadFromXML(true)) {
        if (Creatures::getMonstersList()->hasErrors())
            error('There were some problems loading your monsters.xml file. Please check system/logs/error.log for more info.');
    } else {
        error(Creatures::getLastError());
    }
}

if ($canEdit) {
    ?>
    <form method="post" action="<?php echo getLink('creatures'); ?>">
        <input type="hidden" name="reload_monsters" value="yes"/>
        <input type="submit" value="(admin) Reload monsters"/>
    </form>
    <?php
}

if (empty($_REQUEST['creature'])) {
    //send query to database
    $monsters = $db->query('SELECT * FROM `' . TABLE_PREFIX . 'monsters` WHERE `hidden` != 1 ORDER BY name asc');
    echo '<table id="creaturestb" class=""><thead>
        <tr role="row"><th>Name</th><th>Health</th><th>Experience</th>
    <th>Summonable Mana</th><th>Convinceable Mana</th><th>Race</th></tr>
</thead><tbody>';

    foreach ($monsters as $monster) {
        echo '<tr><td><a href="?subtopic=creatures&creature=' . urlencode($monster['name']) . '">' . $monster['name'] . '</a></td>
        <td>' . $monster['health'] . '</td>
        <td>' . $monster['exp'] . '</td>
        <td>' . ($monster['summonable'] ? $monster['mana'] : "---") . '</td>
        <td>' . ($monster['convinceable'] ? $monster['mana'] : "---") . '</td>
        <td>' . ucwords($monster['race']) . '</td></tr>';
    }
    echo '</tbody></table>';

} else {
    $monster_name = stripslashes(trim(ucwords($_REQUEST['creature'])));
    $monster = $db->query('SELECT * FROM `' . TABLE_PREFIX . 'monsters` WHERE `hidden` != 1 AND `name` = ' . $db->quote($monster_name) . ';')->fetch();
    if (isset($monster['name'])) {
        $title = $monster['name'] . " - Creatures";

        echo '<div style="text-align:center"><h2>' . $monster['name'] . '</h2></div>';
        echo '<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%><tr><td>
    <TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=60%>';
        $number_of_rows = 0;
        echo '<tr BGCOLOR="' . getStyle($number_of_rows) . '"><td width="100"><b>Health: </b></td><td>' . $monster['health'] . '</td></tr>';
        $number_of_rows++;
        echo '<tr BGCOLOR="' . getStyle($number_of_rows) . '"><td width="100"><b>Experience: </b></td><td>' . $monster['exp'] . '</td></tr>';
        $number_of_rows++;
        echo '<tr BGCOLOR="' . getStyle($number_of_rows) . '"><td width="100"><b>Speed like: </b></td><td>' . $monster['speed_lvl'] . ' level';
        $number_of_rows++;
        if ($monster['use_haste'])
            echo ' (Can use haste)';

        echo '</td></tr>';

        $number_of_rows++;
        if ($monster['summonable'] == 1)
            echo '<tr BGCOLOR="' . getStyle($number_of_rows) . '"><td width="100"><b>Summon: </b></td><td>' . $monster['mana'] . ' mana</td></tr>';
        else {
            echo '<tr BGCOLOR="' . getStyle($number_of_rows) . '"><td width="100"><b>Summon: </b></td><td>Impossible</td></tr>';
        }

        $number_of_rows++;
        if ($monster['convinceable'] == 1)
            echo '<tr BGCOLOR="' . getStyle($number_of_rows) . '"><td width="100"><b>Convince: </b></td><td>' . $monster['mana'] . ' mana</td></tr>';
        else
            echo '<tr BGCOLOR="' . getStyle($number_of_rows) . '"><td width="100"><b>Convince: </b></td><td>Impossible</td></tr>';

        echo '</TABLE></td><td align=left>
    <TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=40%>
    <tr><td align=left>';
        $monster['gfx_name'] = trim(strtolower($monster['name'])) . ".gif";
        if (!file_exists('images/monsters/' . $monster['gfx_name'])) {
            $gfx_name = str_replace(" ", "", $monster['gfx_name']);
            if (file_exists('images/monsters/' . $gfx_name))
                echo '<img src="images/monsters/' . $gfx_name . '" height="128" width="128">';
            else
                echo '<img src="images/monsters/nophoto.png" height="128" width="128">';
        } else
            echo '<img src="images/monsters/' . $monster['gfx_name'] . '" height="128" width="128">';

        echo '</td></tr>
    </TABLE></td></tr><tr><td>
    <TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%>';
        $immunities = json_decode($monster['immunities'], true);
        if (count($immunities) > 0) {
            $number_of_rows++;
            echo '<tr BGCOLOR="' . getStyle($number_of_rows) . '"><td width="100"><b>Immunities: </b></td><td width="100%">' . implode(', ', $immunities) . '</td></tr>';
        }

        $voices = json_decode($monster['voices'], true);
        if (count($voices) > 0) {
            foreach ($voices as &$voice) {
                $voice = '"' . $voice . '"';
            }

            $number_of_rows++;
            echo '<tr BGCOLOR="' . getStyle($number_of_rows) . '"><td width="100"><b>Voices: </b></td><td width="100%">' . implode(', ', $voices) . '</td></tr>';
        }
        echo '</TABLE></td></tr>';

        $loot = json_decode($monster['loot'], true);
        if ($loot) {
            echo '<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%><tr><td style="display: block;">';
            function sort_by_chance($a, $b)
            {
                if ($a['chance'] == $b['chance']) {
                    return 0;
                }
                return ($a['chance'] > $b['chance']) ? -1 : 1;
            }

            usort($loot, 'sort_by_chance');

            $i = 0;
            foreach ($loot as $item) {
                $name = getItemNameById($item['id']);
                $tooltip = $name . '<br/>Chance: ' . round($item['chance'] / 1000, 2) . '%<br/>Max count: ' . $item['count'];

                echo '<img src="' . $config['item_images_url'] . $item['id'] . '.gif" class="item_image" title="' . $tooltip . '" width="32" height="32" border="0" alt=" ' . $name . '" />';
                $i++;
            }

            echo '</td></tr></TABLE>';
        }

        echo '</td></tr>';
        echo '</TABLE>';
    } else {
        echo "Monster with name <b>" . $monster_name . "</b> doesn't exist.";
    }

//back button
    $twig->display('creatures.back_button.html.twig');
}
?>
<script>
    $(document).ready(function () {
        $('#creaturestb').DataTable();
    });

</script>

<script src="<?php echo BASE_URL; ?>tools/js/jquery.dataTables.min.js"></script>

if possible. thank you in advance
 

slaw

Developer
Joined
Aug 27, 2007
Messages
3,282
Solutions
101
Reaction score
766
Location
Germany
GitHub
slawkens
I did it, but well it will cause heavy load on the images server, cause it contains a lot of loot images.

So, better host the images server on your local machine.

Try this:

PHP:
<?php
/**
 * Creatures
 *
 * @package   MyAAC
 * @author    Gesior <[email protected]>
 * @author    Slawkens <[email protected]>
 * @copyright 2019 MyAAC
 * @link      https://my-aac.org
 */
defined('MYAAC') or die('Direct access not allowed!');
$title = "Creatures";

?>
<script type="text/javascript" src="tools/js/tipped.js"></script>
<link rel="stylesheet" type="text/css" href="tools/css/tipped.css"/>
<link rel="stylesheet" href="<?php echo BASE_URL; ?>tools/css/jquery.dataTables.min.css">

<script>
   $(document).ready(function () {
      Tipped.create('.item_image');
   });
</script>

<?php

$canEdit = hasFlag(FLAG_CONTENT_MONSTERS) || admin();
if (isset($_POST['reload_monsters']) && $canEdit) {
   require LIBS . 'creatures.php';
   if (Creatures::loadFromXML(true)) {
      if (Creatures::getMonstersList()->hasErrors())
         error('There were some problems loading your monsters.xml file. Please check system/logs/error.log for more info.');
   } else {
      error(Creatures::getLastError());
   }

   if($cache->enabled()) {
      $cache->delete('creaturesCached');
   }
}

if ($canEdit) {
   ?>
   <form method="post" action="<?php echo getLink('creatures'); ?>">
      <input type="hidden" name="reload_monsters" value="yes"/>
      <input type="submit" value="(admin) Reload monsters"/>
   </form>
   <?php
}

if (empty($_REQUEST['creature'])) {
   if($cache->enabled() && $cache->fetch('creaturesCached', $tmp)) {
      $creaturesCached = unserialize($tmp);
   }

   if(!isset($creaturesCached)) {
      if($cache->enabled()) {
         ob_start();
      }

      //send query to database
      $monsters = $db->query('SELECT * FROM `' . TABLE_PREFIX . 'monsters` WHERE `hidden` != 1 ORDER BY name asc');
      echo '<table id="creaturestb" class=""><thead>
      <tr role="row"><th>Name</th><th>Health</th><th>Experience</th>
   <th>Image</th><th>Loot</th><th>Race</th></tr>
</thead><tbody>';

      function sort_by_chance($a, $b)
      {
         if ($a['chance'] == $b['chance']) {
            return 0;
         }
         return ($a['chance'] > $b['chance']) ? -1 : 1;
      }

      foreach ($monsters as $monster) {
         echo '<tr><td><a href="?subtopic=creatures&creature=' . urlencode($monster['name']) . '">' . $monster['name'] . '</a></td>
      <td>' . $monster['health'] . '</td>
      <td>' . $monster['exp'] . '</td>
      <!--td>' . ($monster['summonable'] ? $monster['mana'] : "---") . '</td-->
      <td align=left>';
         $monster['gfx_name'] = trim(strtolower($monster['name'])) . ".gif";
         if (!is_file('images/monsters/' . $monster['gfx_name'])) {
            $gfx_name = str_replace(" ", "", $monster['gfx_name']);
            if (is_file('images/monsters/' . $gfx_name))
               echo '<img src="images/monsters/' . $gfx_name . '" height="128" width="128">';
            else
               echo '<img src="images/monsters/nophoto.png" height="128" width="128">';
         } else
            echo '<img src="images/monsters/' . $monster['gfx_name'] . '" height="128" width="128">';

         echo '</td><td>
      <!--td>' . ($monster['convinceable'] ? $monster['mana'] : "---") . '</td-->';
         $loot = json_decode($monster['loot'], true);
         if ($loot) {
            echo '<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%><tr><td style="display: block;">';

            usort($loot, 'sort_by_chance');

            $i = 0;
            foreach ($loot as $item) {
               $name = getItemNameById($item['id']);
               $tooltip = $name . '<br/>Chance: ' . round($item['chance'] / 1000, 2) . '%<br/>Max count: ' . $item['count'];

               echo '<img src="' . $config['item_images_url'] . $item['id'] . '.gif" class="item_image" title="' . $tooltip . '" width="32" height="32" border="0" alt=" ' . $name . '" />';
               $i++;
            }

            echo '</td></tr></TABLE>';
         }

         echo '</td>
      <td>' . ucwords($monster['race']) . '</td></tr>';
      }
      echo '</tbody></table>';

      if($cache->enabled()) {
         $creaturesCached = ob_get_clean();

         $cache->set('creaturesCached', serialize($creaturesCached), 3600);
         echo $creaturesCached;
      }
   }
   else {
      echo $creaturesCached;
   }

} else {
   $monster_name = stripslashes(trim(ucwords($_REQUEST['creature'])));
   $monster = $db->query('SELECT * FROM `' . TABLE_PREFIX . 'monsters` WHERE `hidden` != 1 AND `name` = ' . $db->quote($monster_name) . ';')->fetch();
   if (isset($monster['name'])) {
      $title = $monster['name'] . " - Creatures";

      echo '<div style="text-align:center"><h2>' . $monster['name'] . '</h2></div>';
      echo '<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%><tr><td>
   <TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=60%>';
      $number_of_rows = 0;
      echo '<tr BGCOLOR="' . getStyle($number_of_rows) . '"><td width="100"><b>Health: </b></td><td>' . $monster['health'] . '</td></tr>';
      $number_of_rows++;
      echo '<tr BGCOLOR="' . getStyle($number_of_rows) . '"><td width="100"><b>Experience: </b></td><td>' . $monster['exp'] . '</td></tr>';
      $number_of_rows++;
      echo '<tr BGCOLOR="' . getStyle($number_of_rows) . '"><td width="100"><b>Speed like: </b></td><td>' . $monster['speed_lvl'] . ' level';
      $number_of_rows++;
      if ($monster['use_haste'])
         echo ' (Can use haste)';

      echo '</td></tr>';

      $number_of_rows++;
      if ($monster['summonable'] == 1)
         echo '<tr BGCOLOR="' . getStyle($number_of_rows) . '"><td width="100"><b>Summon: </b></td><td>' . $monster['mana'] . ' mana</td></tr>';
      else {
         echo '<tr BGCOLOR="' . getStyle($number_of_rows) . '"><td width="100"><b>Summon: </b></td><td>Impossible</td></tr>';
      }

      $number_of_rows++;
      if ($monster['convinceable'] == 1)
         echo '<tr BGCOLOR="' . getStyle($number_of_rows) . '"><td width="100"><b>Convince: </b></td><td>' . $monster['mana'] . ' mana</td></tr>';
      else
         echo '<tr BGCOLOR="' . getStyle($number_of_rows) . '"><td width="100"><b>Convince: </b></td><td>Impossible</td></tr>';

      echo '</TABLE></td><td align=left>
   <TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=40%>
   <tr><td align=left>';
      $monster['gfx_name'] = trim(strtolower($monster['name'])) . ".gif";
      if (!file_exists('images/monsters/' . $monster['gfx_name'])) {
         $gfx_name = str_replace(" ", "", $monster['gfx_name']);
         if (file_exists('images/monsters/' . $gfx_name))
            echo '<img src="images/monsters/' . $gfx_name . '" height="128" width="128">';
         else
            echo '<img src="images/monsters/nophoto.png" height="128" width="128">';
      } else
         echo '<img src="images/monsters/' . $monster['gfx_name'] . '" height="128" width="128">';

      echo '</td></tr>
   </TABLE></td></tr><tr><td>
   <TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%>';
      $immunities = json_decode($monster['immunities'], true);
      if (count($immunities) > 0) {
         $number_of_rows++;
         echo '<tr BGCOLOR="' . getStyle($number_of_rows) . '"><td width="100"><b>Immunities: </b></td><td width="100%">' . implode(', ', $immunities) . '</td></tr>';
      }

      $voices = json_decode($monster['voices'], true);
      if (count($voices) > 0) {
         foreach ($voices as &$voice) {
            $voice = '"' . $voice . '"';
         }

         $number_of_rows++;
         echo '<tr BGCOLOR="' . getStyle($number_of_rows) . '"><td width="100"><b>Voices: </b></td><td width="100%">' . implode(', ', $voices) . '</td></tr>';
      }
      echo '</TABLE></td></tr>';

      $loot = json_decode($monster['loot'], true);
      if ($loot) {
         echo '<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%><tr><td style="display: block;">';

         usort($loot, 'sort_by_chance');

         $i = 0;
         foreach ($loot as $item) {
            $name = getItemNameById($item['id']);
            $tooltip = $name . '<br/>Chance: ' . round($item['chance'] / 1000, 2) . '%<br/>Max count: ' . $item['count'];

            echo '<img src="' . $config['item_images_url'] . $item['id'] . '.gif" class="item_image" title="' . $tooltip . '" width="32" height="32" border="0" alt=" ' . $name . '" />';
            $i++;
         }

         echo '</td></tr></TABLE>';
      }

      echo '</td></tr>';
      echo '</TABLE>';
   } else {
      echo "Monster with name <b>" . $monster_name . "</b> doesn't exist.";
   }

//back button
   $twig->display('creatures.back_button.html.twig');
}
?>
<script>
   $(document).ready(function () {
      $('#creaturestb').DataTable();
   });

</script>

<script src="<?php echo BASE_URL; ?>tools/js/jquery.dataTables.min.js"></script>

Preview:

1614696093399.png
 
OP
OP
Gubailovo

Gubailovo

Member
Joined
Dec 19, 2013
Messages
199
Solutions
1
Reaction score
17
I did it, but well it will cause heavy load on the images server, cause it contains a lot of loot images.

So, better host the images server on your local machine.

Try this:

PHP:
<?php
/**
* Creatures
*
* @package   MyAAC
* @author    Gesior <[email protected]>
* @author    Slawkens <[email protected]>
* @copyright 2019 MyAAC
* @link      https://my-aac.org
*/
defined('MYAAC') or die('Direct access not allowed!');
$title = "Creatures";

?>
<script type="text/javascript" src="tools/js/tipped.js"></script>
<link rel="stylesheet" type="text/css" href="tools/css/tipped.css"/>
<link rel="stylesheet" href="<?php echo BASE_URL; ?>tools/css/jquery.dataTables.min.css">

<script>
   $(document).ready(function () {
      Tipped.create('.item_image');
   });
</script>

<?php

$canEdit = hasFlag(FLAG_CONTENT_MONSTERS) || admin();
if (isset($_POST['reload_monsters']) && $canEdit) {
   require LIBS . 'creatures.php';
   if (Creatures::loadFromXML(true)) {
      if (Creatures::getMonstersList()->hasErrors())
         error('There were some problems loading your monsters.xml file. Please check system/logs/error.log for more info.');
   } else {
      error(Creatures::getLastError());
   }

   if($cache->enabled()) {
      $cache->delete('creaturesCached');
   }
}

if ($canEdit) {
   ?>
   <form method="post" action="<?php echo getLink('creatures'); ?>">
      <input type="hidden" name="reload_monsters" value="yes"/>
      <input type="submit" value="(admin) Reload monsters"/>
   </form>
   <?php
}

if (empty($_REQUEST['creature'])) {
   if($cache->enabled() && $cache->fetch('creaturesCached', $tmp)) {
      $creaturesCached = unserialize($tmp);
   }

   if(!isset($creaturesCached)) {
      if($cache->enabled()) {
         ob_start();
      }

      //send query to database
      $monsters = $db->query('SELECT * FROM `' . TABLE_PREFIX . 'monsters` WHERE `hidden` != 1 ORDER BY name asc');
      echo '<table id="creaturestb" class=""><thead>
      <tr role="row"><th>Name</th><th>Health</th><th>Experience</th>
   <th>Image</th><th>Loot</th><th>Race</th></tr>
</thead><tbody>';

      function sort_by_chance($a, $b)
      {
         if ($a['chance'] == $b['chance']) {
            return 0;
         }
         return ($a['chance'] > $b['chance']) ? -1 : 1;
      }

      foreach ($monsters as $monster) {
         echo '<tr><td><a href="?subtopic=creatures&creature=' . urlencode($monster['name']) . '">' . $monster['name'] . '</a></td>
      <td>' . $monster['health'] . '</td>
      <td>' . $monster['exp'] . '</td>
      <!--td>' . ($monster['summonable'] ? $monster['mana'] : "---") . '</td-->
      <td align=left>';
         $monster['gfx_name'] = trim(strtolower($monster['name'])) . ".gif";
         if (!is_file('images/monsters/' . $monster['gfx_name'])) {
            $gfx_name = str_replace(" ", "", $monster['gfx_name']);
            if (is_file('images/monsters/' . $gfx_name))
               echo '<img src="images/monsters/' . $gfx_name . '" height="128" width="128">';
            else
               echo '<img src="images/monsters/nophoto.png" height="128" width="128">';
         } else
            echo '<img src="images/monsters/' . $monster['gfx_name'] . '" height="128" width="128">';

         echo '</td><td>
      <!--td>' . ($monster['convinceable'] ? $monster['mana'] : "---") . '</td-->';
         $loot = json_decode($monster['loot'], true);
         if ($loot) {
            echo '<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%><tr><td style="display: block;">';

            usort($loot, 'sort_by_chance');

            $i = 0;
            foreach ($loot as $item) {
               $name = getItemNameById($item['id']);
               $tooltip = $name . '<br/>Chance: ' . round($item['chance'] / 1000, 2) . '%<br/>Max count: ' . $item['count'];

               echo '<img src="' . $config['item_images_url'] . $item['id'] . '.gif" class="item_image" title="' . $tooltip . '" width="32" height="32" border="0" alt=" ' . $name . '" />';
               $i++;
            }

            echo '</td></tr></TABLE>';
         }

         echo '</td>
      <td>' . ucwords($monster['race']) . '</td></tr>';
      }
      echo '</tbody></table>';

      if($cache->enabled()) {
         $creaturesCached = ob_get_clean();

         $cache->set('creaturesCached', serialize($creaturesCached), 3600);
         echo $creaturesCached;
      }
   }
   else {
      echo $creaturesCached;
   }

} else {
   $monster_name = stripslashes(trim(ucwords($_REQUEST['creature'])));
   $monster = $db->query('SELECT * FROM `' . TABLE_PREFIX . 'monsters` WHERE `hidden` != 1 AND `name` = ' . $db->quote($monster_name) . ';')->fetch();
   if (isset($monster['name'])) {
      $title = $monster['name'] . " - Creatures";

      echo '<div style="text-align:center"><h2>' . $monster['name'] . '</h2></div>';
      echo '<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%><tr><td>
   <TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=60%>';
      $number_of_rows = 0;
      echo '<tr BGCOLOR="' . getStyle($number_of_rows) . '"><td width="100"><b>Health: </b></td><td>' . $monster['health'] . '</td></tr>';
      $number_of_rows++;
      echo '<tr BGCOLOR="' . getStyle($number_of_rows) . '"><td width="100"><b>Experience: </b></td><td>' . $monster['exp'] . '</td></tr>';
      $number_of_rows++;
      echo '<tr BGCOLOR="' . getStyle($number_of_rows) . '"><td width="100"><b>Speed like: </b></td><td>' . $monster['speed_lvl'] . ' level';
      $number_of_rows++;
      if ($monster['use_haste'])
         echo ' (Can use haste)';

      echo '</td></tr>';

      $number_of_rows++;
      if ($monster['summonable'] == 1)
         echo '<tr BGCOLOR="' . getStyle($number_of_rows) . '"><td width="100"><b>Summon: </b></td><td>' . $monster['mana'] . ' mana</td></tr>';
      else {
         echo '<tr BGCOLOR="' . getStyle($number_of_rows) . '"><td width="100"><b>Summon: </b></td><td>Impossible</td></tr>';
      }

      $number_of_rows++;
      if ($monster['convinceable'] == 1)
         echo '<tr BGCOLOR="' . getStyle($number_of_rows) . '"><td width="100"><b>Convince: </b></td><td>' . $monster['mana'] . ' mana</td></tr>';
      else
         echo '<tr BGCOLOR="' . getStyle($number_of_rows) . '"><td width="100"><b>Convince: </b></td><td>Impossible</td></tr>';

      echo '</TABLE></td><td align=left>
   <TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=40%>
   <tr><td align=left>';
      $monster['gfx_name'] = trim(strtolower($monster['name'])) . ".gif";
      if (!file_exists('images/monsters/' . $monster['gfx_name'])) {
         $gfx_name = str_replace(" ", "", $monster['gfx_name']);
         if (file_exists('images/monsters/' . $gfx_name))
            echo '<img src="images/monsters/' . $gfx_name . '" height="128" width="128">';
         else
            echo '<img src="images/monsters/nophoto.png" height="128" width="128">';
      } else
         echo '<img src="images/monsters/' . $monster['gfx_name'] . '" height="128" width="128">';

      echo '</td></tr>
   </TABLE></td></tr><tr><td>
   <TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%>';
      $immunities = json_decode($monster['immunities'], true);
      if (count($immunities) > 0) {
         $number_of_rows++;
         echo '<tr BGCOLOR="' . getStyle($number_of_rows) . '"><td width="100"><b>Immunities: </b></td><td width="100%">' . implode(', ', $immunities) . '</td></tr>';
      }

      $voices = json_decode($monster['voices'], true);
      if (count($voices) > 0) {
         foreach ($voices as &$voice) {
            $voice = '"' . $voice . '"';
         }

         $number_of_rows++;
         echo '<tr BGCOLOR="' . getStyle($number_of_rows) . '"><td width="100"><b>Voices: </b></td><td width="100%">' . implode(', ', $voices) . '</td></tr>';
      }
      echo '</TABLE></td></tr>';

      $loot = json_decode($monster['loot'], true);
      if ($loot) {
         echo '<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%><tr><td style="display: block;">';

         usort($loot, 'sort_by_chance');

         $i = 0;
         foreach ($loot as $item) {
            $name = getItemNameById($item['id']);
            $tooltip = $name . '<br/>Chance: ' . round($item['chance'] / 1000, 2) . '%<br/>Max count: ' . $item['count'];

            echo '<img src="' . $config['item_images_url'] . $item['id'] . '.gif" class="item_image" title="' . $tooltip . '" width="32" height="32" border="0" alt=" ' . $name . '" />';
            $i++;
         }

         echo '</td></tr></TABLE>';
      }

      echo '</td></tr>';
      echo '</TABLE>';
   } else {
      echo "Monster with name <b>" . $monster_name . "</b> doesn't exist.";
   }

//back button
   $twig->display('creatures.back_button.html.twig');
}
?>
<script>
   $(document).ready(function () {
      $('#creaturestb').DataTable();
   });

</script>

<script src="<?php echo BASE_URL; ?>tools/js/jquery.dataTables.min.js"></script>

Preview:

View attachment 55699
Thank you so much. the number you can explain how to do it, although my server is not very annoying.
Post automatically merged:

another small question. how to reduce the image? editing "height =" 32 "width =" 32 "" has no effect.
 
Last edited:
Top