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

Website Help

athenso

Average Coder
Joined
May 31, 2011
Messages
155
Solutions
3
Reaction score
23
I am trying to get the website to load the reborn information in the players database. I seem to be getting close but I am getting weird outcomes. I know nothing of php.

Code:
<style type="text/css" media="all">
  .Toplevelbox {
    top: -4px;
    position: relative;
    margin-bottom: 10px;
    width: 180px;
    height: 200px;
  }
  .top_level {
    position: absolute;
    top: 29px;
    left: 6px;
    height: 160px;
    width: 168px;
    z-index: 20;
    text-align: center;
    padding-top: 6px;
    font-family: Tahoma, Geneva, sans-serif;
    font-size: 9.2pt;
    color: #FFF;
    font-weight: bold;
    text-align: right;
    text-decoration: inherit;
    text-shadow: 0.1em 0.1em #333
  }

  #Topbar a {
  text-decoration: none;
  cursor: auto;
  }
  a.topfont {
    font-family: Verdana, Arial, Helvetica; 
    font-size: 11px; 
        color: #FF0000;
    text-decoration: none
  }
  a:hover.topfont {
    font-family: Verdana, Arial, Helvetica; 
    font-size: 11px; 
    color: #CCC; 
    text-decoration:none
  }
</style>

<div id="Topbar" class="Themebox" style="background-image:url(<?PHP echo $template_path; ?>/images/themeboxes/highscores/highscores.png);">
  <div class="top_level" style="background:url(<?PHP echo $template_path; ?>/images/themeboxes/bg_top.png)" align="    ">
    <?php
    $skills = $db->query('SELECT reborn FROM players WHERE reborn');
    foreach(getTopPlayers(5) as $player) {
        echo '<div align="left"><a href="'.getPlayerLink($player['name'], false).'" class="topfont">
        <font color="#CCC">&nbsp;&nbsp;&nbsp;&nbsp;'.$player['rank'].' - </font>'.$player['name'].'
        <br>
        <small><font color="white">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Reborn: '.$player['reborn'].'</font></small>
        <br>
      </a>
      </div>';
    }
    ?>
<div class="Bottom" style="background-image:url(<?PHP echo $template_path; ?>/images/general/box-bottom.gif); top: 159px;; left:-5px;">
</div>
</div>
</div>
<br/><br/><br/>


and this is how it looks. There is information and values in the reborn colum.

Screenshot
 
Last edited:
Solution
Modify this function inside of system/functions.php:
Code:
function getTopPlayers($limit = 5) {

change:
Code:
$players = $db->query('SELECT `name`, `level`, `experience` FROM `players` WHERE `group_id` < ' . $config['highscores_groups_hidden'] . ' AND `' . $deleted . '` = 0 AND account_id != 1 ORDER BY `experience` DESC LIMIT 5')->fetchAll();
to:
Code:
$players = $db->query('SELECT `name`, `level`, `experience`, `reborn` FROM `players` WHERE `group_id` < ' . $config['highscores_groups_hidden'] . ' AND `' . $deleted . '` = 0 AND account_id != 1 ORDER BY `experience` DESC LIMIT 5')->fetchAll();
(notice: I've added `reborn` to the query)

Now, you can use that $player['reborn'] in your script. Your script is...
Modify this function inside of system/functions.php:
Code:
function getTopPlayers($limit = 5) {

change:
Code:
$players = $db->query('SELECT `name`, `level`, `experience` FROM `players` WHERE `group_id` < ' . $config['highscores_groups_hidden'] . ' AND `' . $deleted . '` = 0 AND account_id != 1 ORDER BY `experience` DESC LIMIT 5')->fetchAll();
to:
Code:
$players = $db->query('SELECT `name`, `level`, `experience`, `reborn` FROM `players` WHERE `group_id` < ' . $config['highscores_groups_hidden'] . ' AND `' . $deleted . '` = 0 AND account_id != 1 ORDER BY `experience` DESC LIMIT 5')->fetchAll();
(notice: I've added `reborn` to the query)

Now, you can use that $player['reborn'] in your script. Your script is correct, just remove this line cause it's useless:
Code:
$skills = $db->query('SELECT reborn FROM players WHERE reborn');
 
Solution
That was spot on. I spent quite a bit of time looking around, failing to realize there was a functions file for the website. I will have to play around with that when i fix the highscores page. It does work but I think that the line

highscore.php box
Code:
<font color="#CCC">&nbsp;&nbsp;&nbsp;&nbsp;'.$player['rank'].' - </font>'.$player['name'].'

functions.php
or
Code:
        foreach($players as &$player) {
            $player['rank'] = ++$i;
        }

is messing up the file just slightly, Screenshot
 
If you want to display that highscores top 5 sorted by reborns, change in that function getTopPlayers()

this:
Code:
ORDER BY `experience`

to this:
Code:
ORDER BY `reborn`

Or do you mean something different?

BTW. I'm going sleep now, so I will probably answer you tomorrow.
 
Back
Top