- Joined
- Apr 18, 2008
- Messages
- 31
- Reaction score
- 0
MSR - MapleStory Ranking ver 0.3 *update as of wed 30th 8pm GMT+1
update: still ver0.3 but now includes my basic dynamic avatars
see http://forum.ragezone.com/f427/release-wip-avatars-ranks-update2-394571/ for info on the avatar system & how to setup your webserver for it
click
--------------------------------------------------------
if there is something you want to change (be it a "config" setting or such) LOOK at the code as almost everything is commented and should be fairly easy to change/adapt to your needs
--------------------------------------------------------
updated v0.3: mostly GM fixes - can show or hide GM in rankings [ GM_name prefix added ]
nb: GM filter is SERVER SIDE - "random internet guy" viewing rankings CANNOT change it
updated v0.3: new GM job image [thanks patron]
updated v0.3: cleaned code a little bit more [ still messy ]
--------------------------------------------------------
updated v0.2: added working search, fixed rank display, easier to implement into existing page
--------------------------------------------------------
view example here:
--------------------------------------------------------
overall rankings
job [thief / warrior / bowman / mage / beginner / GM]
fame
search
GM filter (show or hide in ranks&search)
--------------------------------------------------------
usage:
include the file, then call either of the functions as below to show rankings
LIMIT would be how many results per page (compact will never have more than "1 page" - advise a limit or 10 or below for that)
showGM is either TRUE (show) or FALSE (hide - default) - leaving it empty will set default
--------------------------------------------------------
bugs:
LET ME KNOW IF YOU FIND A BUG AND/OR THE FIX FOR IT
--------------------------------------------------------
intended updates:
php & mysql (i refer to rank.php but it does NOT matter what you name this as)
--------------------------------------------------------
javascript [required]
--------------------------------------------------------
if you have ver0.1 or ver0.2 and want to see updates, this is my dodgy changelog:
--------------------------------------------------------
images used:
^^^ dont even ask about that one =p
--------------------------------------------------------
download link (includes rank.php & images):
copy/paste code & images or download the .rar file
NB: images must be placed in a SUBFOLDER called /img/ (or CTRL-F find "img/" and change/remove as you see fit)
--------------------------------------------------------
credits to nexon for their images (haha), to patron for his job_gm.gif, everything else is my own work
update: still ver0.3 but now includes my basic dynamic avatars
see http://forum.ragezone.com/f427/release-wip-avatars-ranks-update2-394571/ for info on the avatar system & how to setup your webserver for it
click
To view the content, you need to sign in or register
to download it (contains rank.php + images)--------------------------------------------------------
if there is something you want to change (be it a "config" setting or such) LOOK at the code as almost everything is commented and should be fairly easy to change/adapt to your needs
--------------------------------------------------------
updated v0.3: mostly GM fixes - can show or hide GM in rankings [ GM_name prefix added ]
nb: GM filter is SERVER SIDE - "random internet guy" viewing rankings CANNOT change it
updated v0.3: new GM job image [thanks patron]
updated v0.3: cleaned code a little bit more [ still messy ]
--------------------------------------------------------
updated v0.2: added working search, fixed rank display, easier to implement into existing page
--------------------------------------------------------
view example here:
To view the content, you need to sign in or register
--------------------------------------------------------
overall rankings
job [thief / warrior / bowman / mage / beginner / GM]
fame
search
GM filter (show or hide in ranks&search)
--------------------------------------------------------
usage:
include the file, then call either of the functions as below to show rankings
LIMIT would be how many results per page (compact will never have more than "1 page" - advise a limit or 10 or below for that)
showGM is either TRUE (show) or FALSE (hide - default) - leaving it empty will set default
Code:
include('what_you_name_this_file.php'); // place near top of file
showFullRanking(limit, showGM); // main rankings - @showFullRanking(); will show 25 & hide GM
showCompactRanking(limit, showGM); // mini view for homepage - @showCompactRanking(); will show 5 & hide GM
NOTE: @ before the function will suppress any warnings (usually about argument missing)
bugs:
- there may be issues with fame ranking (unable to test completely)
- images have WHITE backgrounds (modify them yourself or i will eventually - transparent bg) - i checked them out with black backgrounds and they seemed fine? deemed FIXED ver0.3 unless someone states otherwise
- rank # didnt show correctly - FIXED ver0.2
LET ME KNOW IF YOU FIND A BUG AND/OR THE FIX FOR IT
--------------------------------------------------------
intended updates:
- more configurable options
- BETTER images (ya ya i know i know) - not needed anymore?
- cleaner code (class-based = easier to add to pre-existing sites) - almost done xD
- search - done
php & mysql (i refer to rank.php but it does NOT matter what you name this as)
Code:
<?php
// MSR - MapleStory Rankings - ver0.3
// ***************************************
// updates v0.3: mostly GM fixes [show/hide GMs in rankings and prefix names e.g. GM_playername]
// updates v0.3: new GM image (thank you patron)
// ***************************************
// updates v0.2: search, fixed rank (now shows 6,7,8,9,10+ instead of 1,2,3,4,5 again)
// updates v0.2: easier to implement into pre-existing sites using:
// showFullRanking(); - FULL ranking including links & pages etc
// showCompactRanking(); - SMALL ranking - designed for "FRONT PAGE" [i.e. a small top5/10 view]
// ***************************************
// created by minky @ http://minky.mine.nu
// ***************************************
// thanks to nexon for job_thief.gif / job_warrior.gif / job_bowman.gif / job_magician.gif
// thanks to patron for gm_job.gif
// ***************************************
// free to use or modify as you wish
// READ THE COMMENTS PLACED THROUGHOUT IF YOU WANT TO MODIFY ANYTHING
// ***************************************
/* in case you lose it =p [required for job ranks]
<script type="text/javascript" language="JavaScript"><!--
function showHide(obj) {
if(document.getElementById(obj).style.display == "")
{
document.getElementById(obj).style.display = "none";
} else {
document.getElementById(obj).style.display = "";
}
}
//--></script>
*/
function connectDB(){ // open mysql connection - connectDB();
// set these
$host = "localhost";
$user = "root";
$pass = "";
$data = "maplestory"; // database
// leave this
$link = mysql_connect($host, $user, $pass);
if(!$link){
die("MySQL gave this error while attempting to connect --> ". mysql_error()); // error check
}
$db = mysql_select_db($data, $link);
if(!$db){
die("MySQL gave this error while selecting database --> ". mysql_error()); // error check
}
}
function isGM($player, $prefix){ // used inside while(){} - isGM($return['name'], "your_custom_prefix");
if(!isset($prefix) || $prefix == "") $prefix = 'GM_'; // default prefix - change _just_ this bit if you want a different prefix
$query = "SELECT name, job FROM characters WHERE name='". $player ."' LIMIT 1";
connectDB();
$result = mysql_query($query) or die("MySQL gave this error when checking GM status -->". mysql_error()); // error check
$return = mysql_fetch_array($result, MYSQL_ASSOC) or die("MySQL gave this error when fetching GM status -->". mysql_error()); // 1 row = no loop
if($return['job'] == 500 || $return['job'] == 510){ // isGM = TRUE
return $prefix . $player; // user defined GM prefix (or default if not set)
} else {
return $player;
}
}
function showCompactRanking($limit, $showGM){ // a mini-view of the ranking (useful for sidebar top5 etc)
connectDB(); // connect to mysql
if(!isset($limit)) $limit = 5; // default setting
if(!$showGM) $filter = 'WHERE job!=500 AND job!=510 ';
$query = "SELECT * FROM characters ". $filter ."ORDER BY level DESC, exp DESC LIMIT 0, ". $limit; // standard ranking view, order by level then exp
$result = mysql_query($query) or die("MySQL gave this error when loading mini ranks -->". mysql_error()); // error check
// static part of table
echo '<table width="200" border="0" cellspacing="0" cellpadding="0">';
echo '<tr height="50">';
echo '<td width="25">#</td>';
echo '<td width="125">Name</td>';
echo '<td width="50"><div align="center">Level</div></td>';
echo '</tr>';
$i = 1; // the "fix" isnt needed here because there will never be more than 1 page
while($return = mysql_fetch_array($result, MYSQL_ASSOC)){ // start loop - not needed but quicker to write
echo '<tr>';
echo '<td>'. $i .'</td>'; // rank #
echo '<td>'. isGM($return['name'], "") .'</td>'; // name
echo '<td><div align="center">'. $return['level'] .'</div></td>'; // level
echo '</tr>';
$i++;
}
// end of static table
echo '</table>';
mysql_close();
}
function showFullRanking($limit, $showGM){ // showFullRanking(25, showGM); - showGM = TRUE or FALSE
if(!isset($limit)) $limit = 25; // default setting
if(!$showGM){
$filter = 'WHERE job!=500 AND job!=510 ';
$search_filter = 'AND job!=500 AND job!=510 ';
}
$start = (!empty($_GET['s'])) ? $_GET['s'] : 0; // if rank.php?s=VAL is not empty set to VAL else 0
$next = $start+$limit; // for next page link
$prev = ($start == 0) ? 0 : $start-$limit; // if on 0 then cant goto -25
switch($_GET['v']){ // rank.php?v=
case 'thief': // rank.php?v=thief
$viewing = "?v=thief"; // for pages
$query = "SELECT * FROM characters
WHERE job=400 OR job=410 OR job=411 OR job=412 OR job=420 OR job=421 OR job=422
ORDER BY level DESC, exp DESC LIMIT ". $start .", ". $limit;
break;
case 'warrior': // rank.php?v=warrior
$viewing = "?v=warrior"; // pages
$query = "SELECT * FROM characters
WHERE job=100 OR job=110 OR job=111 OR job=112 OR job=120 OR job=121 OR job=122 OR job=130 OR job=131 OR job=132
ORDER BY level DESC, exp DESC LIMIT ". $start .", ". $limit;
break;
case 'mage': // rank.php?v=mage
$viewing = "?v=mage"; // pages
$query = "SELECT * FROM characters
WHERE job=200 OR job=210 OR job=211 OR job=212 OR job=220 OR job=221 OR job=222 OR job=230 OR job=231 OR job=232
ORDER BY level DESC, exp DESC LIMIT ". $start .", ". $limit;
break;
case 'bowman': // rank.php?v=archer
$viewing = "?v=bowman"; // pages
$query = "SELECT * FROM characters
WHERE job=300 OR job=310 OR job=311 OR job=312 OR job=320 OR job=321 OR job=322
ORDER BY level DESC, exp DESC LIMIT ". $start .", ". $limit;
break;
case 'beginner': // rank.php?v=beginner
$viewing = "?v=beginner"; // pages
$query = "SELECT * FROM characters
WHERE job=0 OR job=00 OR job=000
ORDER BY level DESC, exp DESC LIMIT ". $start .", ". $limit;
break;
case 'fame': // rank.php?v=fame
// fame rankings need some work
$viewing = "?v=fame"; // pages
$query = "SELECT * FROM characters
". $filter ."
ORDER BY fame DESC LIMIT ". $start .", ". $limit;
break;
case 'search': // rank.php?v=search
$strip_search = strip_tags($_POST['search']); // no code allowed
$viewing = "?v=search"; // pages
$query = "SELECT * FROM characters
WHERE name LIKE \"%". $strip_search ."%\" ". $search_filter ."
ORDER BY name DESC, level DESC LIMIT 10"; // 10 results max per search
break;
case 'gm': // rank.php?v=gm
$viewing = "?v=gm"; // pages
$query = "SELECT * FROM characters
WHERE job=500 OR job=510
ORDER BY name DESC, level DESC LIMIT ". $start .", ". $limit;
break;
default: // rank.php OR rank.php?v= OR rank.php?v=some_random_thing_not_listed_in_switch
$viewing = "?v="; // pages
$query = "SELECT * FROM characters ". $filter ."ORDER BY level DESC, exp DESC LIMIT ". $start .", ". $limit;
break;
}
connectDB(); // connect to mysql
$result = mysql_query($query) or die("MySQL gave this error when loading ranks -->". mysql_error()); // error check
// the top(static) part of ranking table
// if you want to "integrate" this into a site
// include this page at the location
// ill eventually make it class-based so you can call showRankings(); instead
echo '<table width="500" border="0" cellspacing="0" cellpadding="0">';
echo '<tr height="40">'; // header start (title and such)
echo '<td align="center" colspan="5">';
echo 'MSR - MapleStory Ranking ver0.2<br><br><font size="1">sort rankings by:</font><br>';
echo '</td></tr>'; // header end
echo '<tr height="70">'; // "view ranking links"
echo '<td align="center" valign="top" colspan="5">';
echo '<a href="?v=">Overall</a> - <a href="javascript:showHide(\'jobsearch\')">Job</a> - <a href="?v=fame">Fame</a> - ';
echo '<a href="javascript:showHide(\'search\')">Search</a>';
echo '<div id="search" style="display: none;"><br /><form id="search" name="search" method="post" action="?v=search">'; // start showhide(search)
echo '<input type="text" name="search" id="search" length="30" ';
echo 'onfocus="if(!this._haschanged){this.value=\'\'};this._haschanged=true;" value="search">'; // clear search box on focus
echo '<input type="submit" name="submit" id="submit" value="Go!"></form></div>'; // end of showhide(search)
echo '<div id="jobsearch" style="display: none;"><br>'; // start showhide(jobsearch)
echo '<a href="?v=gm"><img src="img/job_gm.gif" alt="GM" border="0" width="32" height="32"></a> '; // comment out this line to remove GM only view
echo '<a href="?v=warrior"><img src="img/job_warrior.gif" alt="Warrior" border="0" width="32" height="32"></a> ';
echo '<a href="?v=thief"><img src="img/job_thief.gif" alt="Thief" border="0" width="32" height="32"></a> ';
echo '<a href="?v=mage"><img src="img/job_magician.gif" alt="Mage" border="0" width="32" height="32"></a> ';
echo '<a href="?v=bowman"><img src="img/job_bowman.gif" alt="Bowman" border="0" width="32" height="32"></a> ';
echo '<a href="?v=beginner"><img src="img/job_beginner.gif" alt="Beginner" border="0" width="32" height="32"></a>';
echo '</div>'; // end showhide(jobsearch)
echo '</td></tr>'; // end ranking links
echo '<tr height="25" valign="top">'; // leave this
echo '<td width="50">#</td>'; // rank #
echo '<td width="225">Name</td>'; // character name
echo '<td width="125" align="center">Level<br><font size="1">(XP)</font></td>'; // character level
echo '<td width="50" align="center">Fame</td>'; // fame
echo '<td width="50" align="center">Job</td>'; // character job
echo '</tr>';
$i = (empty($_GET['s']) || $_GET['s'] == 0) ? 1 : $_GET['s']+1; // for rank
while($return = mysql_fetch_array($result, MYSQL_ASSOC)){
switch($return['job']){ // check job and return img
case '0':
case '00':
case '000': // beginner
$job_img = '<img src="img/job_beginner.gif" width="32" height="32">';
break;
case '100': // warrior
case '110': case '111': case '112': // fighter / sader / hero
case '120': case '121': case '122': // page / whiteknight / paladin
case '130': case '131': case '132': // spearman / dragonknight / darkknight
$job_img = '<img src="img/job_warrior.gif" width="32" height="32">';
break;
case '200': // magician
case '210': case '211': case '212': // F/P wizard / mage / arch mage
case '220': case '221': case '222': // I/L wizard / mage / arch mage
case '230': case '231': case '232': // cleric / priest / bishop
$job_img = '<img src="img/job_magician.gif" width="32" height="32">';
break;
case '300': // bowman
case '310': case '311': case '312': // hunter / ranger / bowmaster
case '320': case '321': case '322': // xbowman / sniper / marksman
$job_img = '<img src="img/job_bowman.gif" width="32" height="32">';
break;
case '400': // rogue
case '410': case '411': case '412': // assassin / hermit / nightlord
case '420': case '421': case '422': // bandit / chief bandit / shadower
$job_img = '<img src="img/job_thief.gif" width="32" height="32">';
break;
case '500': case '510': // GM & Super GM
$job_img = '<img src="img/job_gm.gif" width="32" height="32">'; // job_GM.gif by Patron~
break;
default: // no image incase of error
$job_img = '<img src="img/denied.gif" width="32" height="32">';
// you probably wont ever see this as its likely to die elsewhere before this shows (just incase tho)
break;
}
echo '<tr height="60">'; // START of rankings
echo '<td>'. $i .'</td>'; // rank
echo '<td>'. isGM($return['name'], "") .'</td>'; // name
echo '<td align="center">'. $return['level'] .'<br><font size="1">('. number_format($return['exp']) .')</font></td>'; // level & formatted XP
echo '<td align="center">'. $return['fame'] .'</td>'; // fame
echo '<td align="center">'. $job_img .'</td>'; // image
echo '</tr>'; // END of rankings
$i++; // set next rank
}
// end of ranking table & pagination (the next/prev links)
echo '<tr><td colspan="5" align="right"><font size="1"><a href="'. $viewing .'&s='. $prev .'">prev</a> - ';
echo '<a href="'. $viewing .'&s='. $next .'">next</a></font></td></tr>';
echo '</table>';
mysql_close();
}
// END OF FILE
echo "Full Ranking:<br>"; // example code [i suggest to remove it]
@showFullRanking(25, TRUE); // example code [i suggest to remove it]
echo "<br><br>Compact Ranking:<br>"; // example code [i suggest to remove it]
@showCompactRanking(5); // example code [i suggest to remove it]
?>
javascript [required]
Code:
<script type="text/javascript" language="JavaScript"><!--
function showHide(obj) {
if(document.getElementById(obj).style.display == "")
{
document.getElementById(obj).style.display = "none";
} else {
document.getElementById(obj).style.display = "";
}
}
//--></script>
if you have ver0.1 or ver0.2 and want to see updates, this is my dodgy changelog:
Code:
ver 0.3 changelog:
function isGM($player, $prefix) - added
function showCompactRanking($limit, $showGM) - modified
function showFullRanking($limit, $showGM) - modified
[ modified SQL queries for show***Ranking() ]
extra job search button: for GM [can be disabled] - added
Code:
ver0.1 - ranking
$i = 1;
ver0.2 - ranking
$i = (empty($_GET['s']) || $_GET['s'] == 0) ? 1 : $_GET['s']+1; // for full rank - NOT for showCompactRanking();
ver 0.1 - links [no search]
echo '<a href="?v=">Overall</a> - <a href="javascript:showHide(\'jobsearch\')">Job</a> - <a href="?v=fame">Fame</a>';
echo '<div id="jobsearch" style="display: none;">'; // for this link ^^^^^
ver 0.2 - links + search
echo '<a href="?v=">Overall</a> - <a href="javascript:showHide(\'jobsearch\')">Job</a> - <a href="?v=fame">Fame</a> - ';
echo '<a href="javascript:showHide(\'search\')">Search</a>';
echo '<div id="search" style="display: none;"><br /><form id="search" name="search" method="post" action="?v=search">'; // start showhide(search)
echo '<input type="text" name="search" id="search" length="30" ';
echo 'onfocus="if(!this._haschanged){this.value=\'\'};this._haschanged=true;" value="search">'; // clear search box on focus
echo '<input type="submit" name="submit" id="submit" value="Go!"></form></div>'; // end of showhide(search)
echo '<div id="jobsearch" style="display: none;">'; // start showhide(jobsearch)
// add case where similar
case 'search': // rank.php?v=search
$viewing = "?v=search"; // pages
$query = "SELECT * FROM characters
WHERE name LIKE \"%". $_POST['search'] ."%\"
ORDER BY name DESC, level DESC LIMIT 10"; // 10 results max per search - no need for more and page links etc
break;
ver0.2
rankings now within functions (to display at your will)
images used:
^^^ dont even ask about that one =p
--------------------------------------------------------
download link (includes rank.php & images):
To view the content, you need to sign in or register
To view the content, you need to sign in or register
To view the content, you need to sign in or register
copy/paste code & images or download the .rar file
NB: images must be placed in a SUBFOLDER called /img/ (or CTRL-F find "img/" and change/remove as you see fit)
--------------------------------------------------------
credits to nexon for their images (haha), to patron for his job_gm.gif, everything else is my own work
Last edited:

