RMX-OS top ten best
Authors: edwardthefma drummer
Type: php script
Introductiontop ten best players buy level
Features
ScreenshotsN/A
Demohttp://ssh.shellium.org/~edwardthefma/Eris%20online%20/topten.php
Script <html>
<body>
<?php
class user {
public $name;
public $lv;
public $exp;
function __construct($name, $lv, $exp) {
$this->name = trim($name, '"');
$this->lv = $lv;
$this->exp = $exp;
}
}
$mysql_access = mysql_connect("sqlhostname", "username", "password");
mysql_select_db("databasename", $mysql_access);
if(!$mysql_access) {
echo "can't connect to db<br>\r\n";
}
else {
$users = array();
$users[0] = new user("nobody", 0, 0);
$topsize = 10; // change this value to chage the number of users displayed ny the top list (i.e. 10 for top10, 5 for top5 etc)
$top = array_fill(0, $topsize, array(0));
$result = mysql_query("SELECT user_id FROM users");
$count = mysql_num_rows($result);
if($topsize > $count) $topsize = $count;
$clistsize = $topsize;
for($i=0; $i<$count; $i++) {
$row = mysql_fetch_assoc($result);
$userid = $row['user_id'];
$res = mysql_query("SELECT data_value FROM save_data WHERE user_id=$userid and data_name='Game_Actors/@data[1]/Game_Actor'");
$aux = mysql_fetch_assoc($res);
$stat = explode(",", trim($aux['data_value']," []"));
$users[$userid] = new user($stat[1], $stat[10], $stat[11]);
$aux = array();
$ctrl = true;
foreach($top as $ids) {
$add = false;
if($ctrl) {
$id = $ids[0];
$r1 = $users[$userid]->lv - $users[$id]->lv;
$r2 = $users[$userid]->exp - $users[$id]->exp;
if(($r1 > 0) || ($r1 == 0) && ($r2 > 0)) {
$aux[] = array($userid);
$ctrl = false;
}
elseif(($r1 == 0) && ($r2 == 0)) {
$aux2 = $ids;
$aux2[] = $userid;
sort($aux2, SORT_NUMERIC);
$aux[] = $aux2;
$ctrl = false;
$add = true;
}
}
if (!$add) $aux[] = $ids;
}
$top = array_slice($aux, 0, $topsize);
}
echo "<table align='center' cellpadding=2 cellspacing=1 border=1 width='40%'>\r\n";
echo "<colgroup span=4 align='center' width='15%'>\r\n";
echo "<col>\r\n";
echo "<col width='55%'>\r\n";
echo "<col span=2>\r\n";
echo "</colgroup>\r\n";
echo "<tr><th colspan=4 bgcolor='#01A8FF'>Top$topsize players</th></tr>\r\n";
echo "<tr align='center' bgcolor='01C0FF'><th>Position</th><th>Name</th><th>Level</th><th>Exp</th></tr>\r\n";
foreach($top as $p1 => $ids) {
$i = 0;
$p = $p1 + 1;
$bgcolor = ($i % 2) ? "01C0FF" : "01A8FF";
foreach($ids as $k => $id) {
echo "<tr bgcolor='#$bgcolor'>";
$i++;
if($k==0) echo "<td rowspan=" . count($ids) . ">$p</td>";
echo "<td><a href='search.php?username=" . $users[$id]->name . "'>" . $users[$id]->name . " ($id)</a></td><td>" . $users[$id]->lv . "</td><td>" . $users[$id]->exp . "</td></tr>\r\n";
}
}
echo "</table>\r\n";
}
?>
</body>
</html>
Instructionsyou will need to make shur you have edited the script to read the data from your games mysql database
Compatibilityworks with any ver of rmx-os this needs the rmx-os profiles script
Credits and Thanksdrummer thanks for the help
Author's Notesyou might want to read up on basic php
That's it! N-Joy! =D