Jump to content
MakeWebGames

[Free] Top 10 Players


Aventro

Recommended Posts

Easy one. Nothing fancy really, just saves some time, it displays top 10 players, you can order the top list via money/level.

 

<?php
//This file cannot be viewed, it must be included
defined('IN_EZRPG') or exit;

class Module_TopPlayers extends Base_Module
{
   public function start()
   {
       //Require login
       requireLogin();

       switch ($_GET['order'])
       {
           case 'level':
               $order = 'level';
           break;
           case 'money':
               $order = 'money';
           break;
           default:
               $order = 'level';
       }

       $query = $this->db->execute('SELECT `username`, `level`, `money` FROM `<ezrpg>players` ORDER BY ' . $order . ' DESC LIMIT 10');
       $members = $this->db->fetchAll($query);

       $this->tpl->assign('members', $members);
       $this->tpl->display('topplayers.tpl');
   }
}

 

topplayers.tpl

 

{include file="header.tpl" TITLE="Top 10 Players"}

<h2>Top 10 Players</h2>

<table width="90%">
 <tr>
   <th style="text-align: left;">Username</th>
   <th style="text-align: left;"><a href="index.php?mod=TopPlayers&order=level">Level</a></th>
   <th style="text-align: left;"><a href="index.php?mod=TopPlayers&order=money">Money</a></th>
 </tr>

{foreach from=$members item=member}
 <tr>
   <td>{$member->username}</td>
   <td>{$member->level}</td>
   <td>{$member->money}</td>
 </tr>
{/foreach}
</table>

{include file="footer.tpl"}

 

Installation

1. Make a folder named TopPlayers in your modules directory.

2. Place the index.php file with the first code snippet above.

3. Place the topplayers.tpl file in the smarty/templates directory with the second code snippet above.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...