• 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!

Help with code of old school layout for ZnoteAcc Code

Felipe93

Ghost Member
Joined
Mar 21, 2015
Messages
1,760
Solutions
9
Reaction score
282
Location
Chile
I'm using this layout [Znote AAC] old school layout with the latest ZnoteAcc Release downloaded from github and the layout is giving few erros like for example this one
Code:
Warning: Undefined array key "looktype" in D:\xampp\htdocs\layout\sub\highscores.php on line 211

Warning: Undefined array key "lookhead" in D:\xampp\htdocs\layout\sub\highscores.php on line 211

Warning: Undefined array key "lookbody" in D:\xampp\htdocs\layout\sub\highscores.php on line 211

Warning: Undefined array key "looklegs" in D:\xampp\htdocs\layout\sub\highscores.php on line 211

Warning: Undefined array key "lookfeet" in D:\xampp\htdocs\layout\sub\highscores.php on line 211
the code that is giving error is this one
Code:
<?php
                            echo '<div style="position:relative; left:-32px; top:-32px;width: 32px;height:32px;">
                            <div style="background-image: url(layout/outfitter/outfit.php?id='.$scores[$type][$i]['looktype'].'&head='.$scores[$type][$i]['lookhead'].'&body='.$scores[$type][$i]['lookbody'].'&legs='.$scores[$type][$i]['looklegs'].'&feet='.$scores[$type][$i]['lookfeet'].');
                                width:64px;height:64px;position:absolute;background-repeat:no-repeat;background-position:right bottom;">
                            </div>';
                        ?>

to be more specific, exactly this line/part:
Code:
'.$scores[$type][$i]['looktype'].'&head='.$scores[$type][$i]['lookhead'].'&body='.$scores[$type][$i]['lookbody'].'&legs='.$scores[$type][$i]['looklegs'].'&feet='.$scores[$type][$i]['lookfeet'].');

I have understood that this layout was made for oldschool servers ( 7.72 ) but im using a newer version (8.6) so that might be causing the issue or the layout it's not longer complatible with ZnoteAcc or something beucase it's was made on another Znoteacc version.
The thing is that how could i adapt the code to make it compatible with newer versions or even how could remove part of the code properly to get it working without outfit displaying.
or adapt it. I have checked un-edited highscores.php


Lua:
                        <?php if ($loadOutfits): ?>
                            <td class="outfitColumn"><img src="<?php echo $config['show_outfits']['imageServer']; ?>?id=<?php echo $vocGroup[$type][$i]['type']; ?>&addons=<?php echo $vocGroup[$type][$i]['addons']; ?>&head=<?php echo $vocGroup[$type][$i]['head']; ?>&body=<?php echo $vocGroup[$type][$i]['body']; ?>&legs=<?php echo $vocGroup[$type][$i]['legs']; ?>&feet=<?php echo $vocGroup[$type][$i]['feet']; ?>" alt="img"></td>
                        <?php endif; ?>
                        <td><?php echo $i+1; ?></td>
                        <td><?php echo $flag; ?><a href="characterprofile.php?name=<?php echo $vocGroup[$type][$i]['name']; ?>"><?php echo $vocGroup[$type][$i]['name']; ?></a></td>
                        <td><?php echo vocation_id_to_name($vocGroup[$type][$i]['vocation']); ?></td>
                        <td><?php echo $vocGroup[$type][$i]['value']; ?></td>
                        <?php if ($type === 7) echo "<td>". $vocGroup[$type][$i]['experience'] ."</td>"; ?>
but i can't get it to work in this highscore.php from the layout.

Please Help
 

tarantonio

Old School Player
Joined
Jun 21, 2009
Messages
826
Solutions
1
Reaction score
235
Just try to delete td that contains the outfit, but the problem seems to be that you are trying to use an array not defined as the error says.
 
OP
OP
Felipe93

Felipe93

Ghost Member
Joined
Mar 21, 2015
Messages
1,760
Solutions
9
Reaction score
282
Location
Chile
Bump i have deleted the things related to outfits and now it works.but vocations are not being displayed properly at highscores it shows anyvocation and array :/ nothing else
website error.png
 
OP
OP
Felipe93

Felipe93

Ghost Member
Joined
Mar 21, 2015
Messages
1,760
Solutions
9
Reaction score
282
Location
Chile
Maybe you get rid of that line -> <td><?php echo vocation_id_to_name($vocGroup[$type][$i]['vocation']); ?></td>
No i did not mate, I noticed with the original file that the error was always there. And that line is not even written in that way in this highscores.php file that it's in layout/sub/highscores.php is not the original ZnoteAcc highscores.php, that you are reviewing. It's the one that comes with the old tibia layout posted in the main post. I'm using this layout in other protocol (8.60) appart of what it was made for that it's 7.6 so it don't handle addons in the code itself etc.
( but that's not the issue now since i have removed the code )
Also maybe it's old so it might have some variables / declatarions etc outdated or that are pointing to nowhere.

here you can see the website before my editions and the error was there.

error 2.png
This is the Original highscores.php that comes at layout/sub folder and it has the same problem.
So ofc something is wrong but the probleme were there before i edited something anyway.
I must add that i also i changed everything from $vocation to $vocGroup just to test and check but didn't worked. The error seems to be here as far i can see, but not sure anyway. ( or with something related to it. but don't know where else to check):
PHP:
    <option value="-1" <?php if ($vocation < 0) echo "selected"; ?>>Any vocation</option>

            <?php
            foreach (config('vocations') as $v_id => $v_name) {
                $selected = ($vocation == $v_id) ? " selected" : NULL;

                echo '<option value="'. $v_id .'"'. $selected .'>'. $v_name .'</option>';
            }
            ?>
I replaced the code with the code updated (and it's variables ) and even more. but didn't worked

PHP:
    <option value="all" <?php if (!is_int($vocation)) echo "selected"; ?>>Any vocation</option>
            <?php
            foreach ($configVocations as $v_id => $v_data) {
                if ($v_data['fromVoc'] === false) {
                    $selected = (is_int($vocation) && $vocation == $v_id) ? " selected $vocation = $v_id" : "";
                    echo '<option value="'. $v_id .'"'. $selected .'>'. $v_data['name'] .'</option>';
                }
            }
            ?>

So i want a work arround or idea or even the code to fix the highscorepage.
As you can see this is the original file without editions that also has the error related to non displaying vocations and the word "array".
PHP:
<?php require_once 'engine/init.php';

if ($config['log_ip']) {
    znote_visitor_insert_detailed_data(3);
}

function fetchAllScoresh($rows, $tfs, $g, $v = -1) {
    // Return scores ordered by type and vocation (if set)
    $data = array();
    if ($tfs == 'TFS_10') {

        // Generate SQL WHERE-clause for vocation if $v is set
        $v = ($v > -1) ? 'AND `vocation` = '. intval($v) : NULL;

        $data[1] = mysql_select_multi("SELECT `id`, `name`, `vocation`, `skill_club` AS `value` FROM `players` WHERE `group_id` < $g $v ORDER BY `skill_club` DESC LIMIT 0, $rows;");
        $data[2] = mysql_select_multi("SELECT `id`, `name`, `vocation`, `skill_sword` AS `value` FROM `players` WHERE `group_id` < $g $v ORDER BY `skill_sword` DESC LIMIT 0, $rows;");
        $data[3] = mysql_select_multi("SELECT `id`, `name`, `vocation`, `skill_axe` AS `value` FROM `players` WHERE `group_id` < $g $v ORDER BY `skill_axe` DESC LIMIT 0, $rows;");
        $data[4] = mysql_select_multi("SELECT `id`, `name`, `vocation`, `skill_dist` AS `value` FROM `players` WHERE `group_id` < $g $v ORDER BY `skill_dist` DESC LIMIT 0, $rows;");
        $data[5] = mysql_select_multi("SELECT `id`, `name`, `vocation`, `skill_shielding` AS `value` FROM `players` WHERE `group_id` < $g $v ORDER BY `skill_shielding` DESC LIMIT 0, $rows;");
        $data[6] = mysql_select_multi("SELECT `id`, `name`, `vocation`, `skill_fishing` AS `value` FROM `players` WHERE `group_id` < $g $v ORDER BY `skill_fishing` DESC LIMIT 0, $rows;");
        $data[7] = mysql_select_multi("SELECT `id`, `name`, `vocation`, `experience`, `level` AS `value` FROM `players` WHERE `group_id` < $g $v ORDER BY `experience` DESC LIMIT 0, $rows;");
        $data[8] = mysql_select_multi("SELECT `id`, `name`, `vocation`, `maglevel` AS `value` FROM `players` WHERE `group_id` < $g $v ORDER BY `maglevel` DESC LIMIT 0, $rows;");
        $data[9] = mysql_select_multi("SELECT `id`, `name`, `vocation`, `skill_fist` AS `value` FROM `players` WHERE `group_id` < $g $v ORDER BY `skill_fist` DESC LIMIT 0, $rows;");
    } else {

        // Generate SQL WHERE-clause for vocation if $v is set
        $v = ($v > -1) ? 'AND `vocation` = '. intval($v) : NULL;

        $data[9] = mysql_select_multi("SELECT `looktype`, `lookhead`, `lookbody`, `looklegs`, `lookfeet`, `s`.`player_id` AS `id`, `s`.`value` AS `value`, `p`.`name` AS `name`, `p`.`vocation` AS `vocation` FROM `player_skills` AS `s` LEFT JOIN `players` AS `p` ON `s`.`player_id`=`p`.`id` WHERE `s`.`skillid` = 0 AND `p`.`group_id` < $g $v ORDER BY `s`.`value` DESC LIMIT 0, $rows;");
        $data[1] = mysql_select_multi("SELECT `looktype`, `lookhead`, `lookbody`, `looklegs`, `lookfeet`, `s`.`player_id` AS `id`, `s`.`value` AS `value`, `p`.`name` AS `name`, `p`.`vocation` AS `vocation` FROM `player_skills` AS `s` LEFT JOIN `players` AS `p` ON `s`.`player_id`=`p`.`id` WHERE `s`.`skillid` = 1 AND `p`.`group_id` < $g $v ORDER BY `s`.`value` DESC LIMIT 0, $rows;");
        $data[2] = mysql_select_multi("SELECT `looktype`, `lookhead`, `lookbody`, `looklegs`, `lookfeet`, `s`.`player_id` AS `id`, `s`.`value` AS `value`, `p`.`name` AS `name`, `p`.`vocation` AS `vocation` FROM `player_skills` AS `s` LEFT JOIN `players` AS `p` ON `s`.`player_id`=`p`.`id` WHERE `s`.`skillid` = 2 AND `p`.`group_id` < $g $v ORDER BY `s`.`value` DESC LIMIT 0, $rows;");
        $data[3] = mysql_select_multi("SELECT `looktype`, `lookhead`, `lookbody`, `looklegs`, `lookfeet`, `s`.`player_id` AS `id`, `s`.`value` AS `value`, `p`.`name` AS `name`, `p`.`vocation` AS `vocation` FROM `player_skills` AS `s` LEFT JOIN `players` AS `p` ON `s`.`player_id`=`p`.`id` WHERE `s`.`skillid` = 3 AND `p`.`group_id` < $g $v ORDER BY `s`.`value` DESC LIMIT 0, $rows;");
        $data[4] = mysql_select_multi("SELECT `looktype`, `lookhead`, `lookbody`, `looklegs`, `lookfeet`, `s`.`player_id` AS `id`, `s`.`value` AS `value`, `p`.`name` AS `name`, `p`.`vocation` AS `vocation` FROM `player_skills` AS `s` LEFT JOIN `players` AS `p` ON `s`.`player_id`=`p`.`id` WHERE `s`.`skillid` = 4 AND `p`.`group_id` < $g $v ORDER BY `s`.`value` DESC LIMIT 0, $rows;");
        $data[5] = mysql_select_multi("SELECT `looktype`, `lookhead`, `lookbody`, `looklegs`, `lookfeet`, `s`.`player_id` AS `id`, `s`.`value` AS `value`, `p`.`name` AS `name`, `p`.`vocation` AS `vocation` FROM `player_skills` AS `s` LEFT JOIN `players` AS `p` ON `s`.`player_id`=`p`.`id` WHERE `s`.`skillid` = 5 AND `p`.`group_id` < $g $v ORDER BY `s`.`value` DESC LIMIT 0, $rows;");
        $data[6] = mysql_select_multi("SELECT `looktype`, `lookhead`, `lookbody`, `looklegs`, `lookfeet`, `s`.`player_id` AS `id`, `s`.`value` AS `value`, `p`.`name` AS `name`, `p`.`vocation` AS `vocation` FROM `player_skills` AS `s` LEFT JOIN `players` AS `p` ON `s`.`player_id`=`p`.`id` WHERE `s`.`skillid` = 6 AND `p`.`group_id` < $g $v ORDER BY `s`.`value` DESC LIMIT 0, $rows;");
        $data[7] = mysql_select_multi("SELECT `looktype`, `lookhead`, `lookbody`, `looklegs`, `lookfeet`, `id`, `name`, `vocation`, `experience`, `level` AS `value` FROM `players` WHERE `group_id` < $g $v ORDER BY `experience` DESC limit 0, $rows;");
        $data[8] = mysql_select_multi("SELECT `looktype`, `lookhead`, `lookbody`, `looklegs`, `lookfeet`, `id`, `name`, `vocation`, `maglevel` AS `value` FROM `players` WHERE `group_id` < $g $v ORDER BY `maglevel` DESC limit 0, $rows;");
    }
    return $data;
}

// Fetch highscore type
$type = (isset($_GET['type'])) ? (int)getValue($_GET['type']) : 7;
if ($type > 9) $type = 7;

// Fetch highscore vocation
$vocation = (isset($_GET['vocation'])) ? (int)getValue($_GET['vocation']) : -1;
if ($vocation > 8) $vocation = -1;

// Fetch highscore page
$page = getValue(@$_GET['pag']);
if (!$page || $page == 0) $page = 1;
else $page = (int)$page;

$highscore = $config['highscore'];

$rows = $highscore['rows'];
$rowsPerPage = $highscore['rowsPerPage'];

function skillName($type) {
    $types = array(
        1 => "Club",
        2 => "Sword",
        3 => "Axe",
        4 => "Distance",
        5 => "Shield",
        6 => "Fish",
        7 => "Experience", // Hardcoded
        8 => "Magic Level", // Hardcoded
        9 => "Fist", // Since 0 returns false I will make 9 = 0. :)
    );
    return $types[(int)$type];
}

function pageCheck($index, $page, $rowPerPage) {
    return ($index < ($page * $rowPerPage) && $index >= ($page * $rowPerPage) - $rowPerPage) ? true : false;
}

$cache = new Cache('engine/cache/highscores');
if ($cache->hasExpired()) {
    $scores = fetchAllScoresh($rows, $config['TFSVersion'], $highscore['ignoreGroupId'], $vocation);
 
    $cache->setContent($scores);
    $cache->save();
} else {
    $scores = $cache->load();
}

if ($scores) {
    ?>
        <style>
            .newstext img
            {
                max-width: 562px;
                height: auto;
                margin: 0 5px;
            }
            .pagination
            {
                text-align: center;
                margin: 10px 0;
            }
            .pagination a
            {
                display: inline-block;
                color: #52412f;
                font-size: 14px;
                line-height: 24px;
                height: 24px;
                width: 24px;
                font-weight: bold;
                text-align: center;
                border: 1px solid #886a4d;
                margin: 0 5px 0 0;
                border-radius: 24px;
                box-shadow: 0 2px 3px rgb(255, 214, 175) inset;
                background: #dcaf83;
                transition: opacity 0.1s linear;
            }
            .pagination a:hover
            {
                opacity: 0.7;
            }
            .pagination a.current
            {
                background: #ad1a1a;
                color: #fff;
                border: 1px solid #000000;
                box-shadow: 0 2px 3px rgb(255, 62, 62) inset;
            }
        </style>
  
    <form type="submit" action="" method="GET">
    <br>
    <center>Skill: <input type="hidden" name="page" value="highscores"/>
        <select style="vertical-align:middle;" name="type">
            <option value="7" <?php if ($type == 7) echo "selected"; ?>>Experience</option>
            <option value="8" <?php if ($type == 8) echo "selected"; ?>>Magic</option>
            <option value="5" <?php if ($type == 5) echo "selected"; ?>>Shield</option>
            <option value="2" <?php if ($type == 2) echo "selected"; ?>>Sword</option>
            <option value="1" <?php if ($type == 1) echo "selected"; ?>>Club</option>
            <option value="3" <?php if ($type == 3) echo "selected"; ?>>Axe</option>
            <option value="4" <?php if ($type == 4) echo "selected"; ?>>Distance</option>
            <option value="6" <?php if ($type == 6) echo "selected"; ?>>Fish</option>
            <option value="9" <?php if ($type == 9) echo "selected"; ?>>Fist</option>
        </select>
        &nbsp;&nbsp;Vocation: <select style="vertical-align:middle;" name="vocation">
            <option value="-1" <?php if ($vocation < 0) echo "selected"; ?>>Any vocation</option>

            <?php
            foreach (config('vocations') as $v_id => $v_name) {
                $selected = ($vocation == $v_id) ? " selected" : NULL;

                echo '<option value="'. $v_id .'"'. $selected .'>'. $v_name .'</option>';
            }
            ?>
        </select>
  
         <input type="submit" class="hover" value=""
    style="background-image: url(layout/tibia_img/sbutton_submit.gif); vertical-align:middle; border: solid 0px #000000; width: 120px; height: 18px;" />
        </center>
    </form>
 
 
        <br><center><span class="pagination">
            <?php
            $pages = ceil(min(($highscore['rows'] / $highscore['rowsPerPage']), (count($scores[$type]) / $highscore['rowsPerPage'])));
            for ($i = 0; $i < $pages; $i++) {
                $x = $i + 1;
                if ($x == $page) echo "<a href=\"?".$_SERVER['QUERY_STRING']."&pag=".$x."\" class=\"current\">".$x."</a>";
                else echo "<a href=\"?".$_SERVER['QUERY_STRING']."&pag=".$x."\">".$x."</a>";
            }
            ?>
        </span></center>
  
  
    <table id="highscoresTable" cellpadding="4" class="stripped">
        <tr>
            <th colspan="7">Ranking for <?php echo skillName($type) .", ". (($vocation < 0) ? 'any vocation' : vocation_id_to_name($vocation)) ?></th>
        </tr>
        <tr>
            <td width="8%"><center>#</center></td>
            <td width="8%"><center><strong>outfit</strong></center></td>
            <?php if ($config['country_flags'] === true) echo'<td width="5%"><center><strong>flag</strong></center></td>'; ?>
            <td><strong>Name</strong></td>
            <td><center><strong>Vocation</strong></center></td>
            <td width="15%"><center><strong>Level</strong></center></td>
            <?php if ($type === 7) echo "<td width=\"15%\"><center><strong>Points</strong></center></td>"; ?>
        </tr>
        <?php
        for ($i = 0; $i < count($scores[$type]); $i++) {
            if ($scores[$type] === false) {
                ?>
                <tr>
                    <td colspan="7">Nothing to show here yet.</td>
                </tr>
                <?php
            } else {
                if (pageCheck($i, $page, $rowsPerPage)) {
                    $profile_data = user_character_data($scores[$type][$i]['id'], 'account_id');

                    $account_data = user_znote_account_data($profile_data['account_id'], 'flag');
                    if ($config['country_flags'] === true) $flag = '<td><center><img src="flags/' . $account_data['flag'] . '.png"></center></td>';
                    else $flag = '';
                    ?>
                    <tr>
                        <td><center><?php echo $i+1; ?>.</center></td>
                        <td>
                        <?php
                            echo '<div style="position:relative; left:-32px; top:-32px;width: 32px;height:32px;">
                            <div style="background-image: url(layout/outfitter/outfit.php?id='.$scores[$type][$i]['looktype'].'&head='.$scores[$type][$i]['lookhead'].'&body='.$scores[$type][$i]['lookbody'].'&legs='.$scores[$type][$i]['looklegs'].'&feet='.$scores[$type][$i]['lookfeet'].');
                                width:64px;height:64px;position:absolute;background-repeat:no-repeat;background-position:right bottom;">
                            </div>';
                        ?>
              
                        </td>
                        <?php echo $flag; ?>
                        <td><strong><a href="characterprofile.php?name=<?php echo $scores[$type][$i]['name']; ?>"><?php echo $scores[$type][$i]['name']; ?></a></strong></td>
                        <td><center><?php echo vocation_id_to_name($scores[$type][$i]['vocation']); ?></center></td>
                        <td><center><?php echo $scores[$type][$i]['value']; ?></center></td>
                        <?php if ($type === 7) echo "<td><center>". $scores[$type][$i]['experience'] ."</center></td>"; ?>
                    </tr>
                    <?php
                }
            }
        }
        ?>
    </table>
        <center><span class="pagination">
            <?php
            $pages = ceil(min(($highscore['rows'] / $highscore['rowsPerPage']), (count($scores[$type]) / $highscore['rowsPerPage'])));
            for ($i = 0; $i < $pages; $i++) {
                $x = $i + 1;
                if ($x == $page) echo "<a href=\"?".$_SERVER['QUERY_STRING']."&pag=".$x."\" class=\"current\">".$x."</a>";
                else echo "<a  href=\"?".$_SERVER['QUERY_STRING']."&pag=".$x."\">".$x."</a>";
            }
            ?>
        </span></center>
    <?php
}
?>
and here it's the edited one
PHP:
<!-- >?php -->
                            <!-- echo '<div style="position:relative; left:-32px; top:-32px;width: 32px;height:32px;"> -->
                            <!-- <div style="background-image: url(layout/outfitter/outfit.php?id='.$scores[$type][$i]['looktype'].'&head='.$scores[$type][$i]['lookhead'].'&body='.$scores[$type][$i]['lookbody'].'&legs='.$scores[$type][$i]['looklegs'].'&feet='.$scores[$type][$i]['lookfeet'].'); -->
                                <!-- width:64px;height:64px;position:absolute;background-repeat:no-repeat;background-position:right bottom;"> -->
                            <!-- </div>'; -->
                        <!-- ?> -->
 
Last edited:

tarantonio

Old School Player
Joined
Jun 21, 2009
Messages
826
Solutions
1
Reaction score
235
You have to define the vocation array anywhere, look at the config.php, there is an array about vocation.

PHP:
// Vocation IDs, names and which vocation ID they got promoted from
    $config['vocations'] = array(
        0 => array(
            'name' => 'No vocation',
            'fromVoc' => false
        ),
        1 => array(
            'name' => 'Sorcerer',
            'fromVoc' => false
        ),
        2 => array(
            'name' => 'Druid',
            'fromVoc' => false
        ),
        3 => array(
            'name' => 'Paladin',
            'fromVoc' => false
        ),
        4 => array(
            'name' => 'Knight',
            'fromVoc' => false
        ),
        5 => array(
            'name' => 'Master Sorcerer',
            'fromVoc' => 1
        ),
        6 => array(
            'name' => 'Elder Druid',
            'fromVoc' => 2
        ),
        7 => array(
            'name' => 'Royal Paladin',
            'fromVoc' => 3
        ),
        8 => array(
            'name' => 'Elite Knight',
            'fromVoc' => 4
        )
    );

Then try with something like this in the GET part:
PHP:
<select name="vocation">
            <option value="all" <?php if (!is_int($vocation)) echo "selected"; ?>>Any vocation</option>
            <?php
            foreach ($configVocations as $v_id => $v_data) {
                if ($v_data['fromVoc'] === false) {
                    $selected = (is_int($vocation) && $vocation == $v_id) ? " selected $vocation = $v_id" : "";
                    echo '<option value="'. $v_id .'"'. $selected .'>'. $v_data['name'] .'</option>';
                }
            }
            ?>
        </select>
 
Last edited:
OP
OP
Felipe93

Felipe93

Ghost Member
Joined
Mar 21, 2015
Messages
1,760
Solutions
9
Reaction score
282
Location
Chile
Bump! I have updated the whole highscores.php comparing it with Znote's one and Now it's "working" the search bar is displaying the different vocations
but if you check at the highscore list there's no one in it. Please Help!
error 3.png

this is what i have done so far.( can't post it here as a code)
 

Attachments

  • updated highscores.txt
    20.9 KB · Views: 2 · VirusTotal
Top