Aventro Posted March 9, 2013 Share Posted March 9, 2013 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. Quote Link to comment Share on other sites More sharing options...
Spudinski Posted March 10, 2013 Share Posted March 10, 2013 (edited) Tested, confirmed and implemented in ezRPG Rework. Edited March 10, 2013 by Spudinski Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.