spiky1471 Posted July 10, 2009 Posted July 10, 2009 Add this to global_funcs.php this MUST go at the bottom of the page function get_rank($stat, $mykey) { global $ir,$userid,$c; $q=mysql_query("SELECT count(*) FROM userstats us LEFT JOIN users u ON us.userid=u.userid WHERE us.$mykey > $stat AND us.userid != $userid AND u.user_level != 0", $c) ; return mysql_result($q,0,0)+1; } function get_gamerank($level, $housevalue, $stats) { $tp=($level*$level) * 3000 + ($housevalue) + (($stats['strength']+$stats['agility']+$stats['guard']+$stats['labour']+$stats['IQ']) * 10); if ( $tp < 100000 ) { return "#1 First Newbie"; } else if ( $tp < 400000 ) { return "#2 Newbie"; } else if ( $tp < 1600000 ) { return "#3 Beginner"; } else if ( $tp < 6400000 ) { return "#4 Not Experienced"; } else if ( $tp < 25600000 ) { return "#5 Rookie"; } else if ( $tp < 102400000 ) { return "#6 Average"; } else if ( $tp < 409600000 ) { return "#7 Good"; } else if ( $tp < 819200000 ) { return "#8 Very Good"; } else if ( $tp < 3276800000 ) { return "#9 Greater Than Average"; } else if ( $tp < 13107200000 ) { return "#10 Experienced"; } else if ( $tp < 52428800000 ) { return "#11 Highly Experienced"; } else if ( $tp < 209715200000 ) { return "#12 Honoured"; } else if ( $tp < 838860800000 ) { return "#13 Highly Hounoured"; } else if ( $tp < 3355443200000 ) { return "#14 Respect King"; } else if ( $tp < 6655886400000 ) { return "#15 True Champion"; } } Add this to viewuser.php [b]Rank:[/b] ".get_gamerank($r['level'],$r['hPRICE'],$r)." Ok i was given this mod here - i think its a free one as i see it on mccodes website but no download link Anyway - i was getting someone to set game up and mods etc etc but when i gave them this they said there should be an SQL file. Now should there be an SQL File to go with this ? And if this is a free mod - can someone upload it for me to download with sql Quote
Miniman Posted July 10, 2009 Posted July 10, 2009 Re: Game Ranks Mod This doesn't need any additions to your DB...... Why didn't you just add it and see if an error appeared ? :) Quote
spiky1471 Posted July 10, 2009 Author Posted July 10, 2009 Re: Game Ranks Mod This doesn't need any additions to your DB...... Why didn't you just add it and see if an error appeared ? :) hmm guess i coulda done that lol thx though +1 for u Quote
cjelliott Posted January 10, 2013 Posted January 10, 2013 didnt work for me tho not many codes seem to be working for me lately any1 know why this wont work? if ($r['level'] < 10) {$rank="rank 1";} else if ($r['level'] < 25) {$rank="rank 2";} else if ($r['level'] < 50) {$rank="rank 3";} else if ($r['level'] < 100) {$rank="rank 4";} else if ($r['level'] < 250) {$rank="rank 5";} else if ($r['level'] < 1000) {$rank="rank 6";} else {$rank="rank 7";} im on v2 if u any1 gets this to work or knows whats wrong with it please tell me how to fix it thanks ps i got a feeling its just that ive placed the code in the wrong place within viewuser.php Quote
sniko Posted January 10, 2013 Posted January 10, 2013 didnt work for me tho not many codes seem to be working for me lately any1 know why this wont work? if ($r['level'] < 10) {$rank="rank 1";} else if ($r['level'] < 25) {$rank="rank 2";} else if ($r['level'] < 50) {$rank="rank 3";} else if ($r['level'] < 100) {$rank="rank 4";} else if ($r['level'] < 250) {$rank="rank 5";} else if ($r['level'] < 1000) {$rank="rank 6";} else {$rank="rank 7";} im on v2 if u any1 gets this to work or knows whats wrong with it please tell me how to fix it thanks ps i got a feeling its just that ive placed the code in the wrong place within viewuser.php Paste your viewuser source, then Quote
sniko Posted January 10, 2013 Posted January 10, 2013 here <?php include "globals.php"; if ($r['level'] < 10) {$rank="rank 1";} else if ($r['level'] < 25) {$rank="rank 2";} else if ($r['level'] < 50) {$rank="rank 3";} else if ($r['level'] < 100) {$rank="rank 4";} else if ($r['level'] < 250) {$rank="rank 5";} else if ($r['level'] < 1000) {$rank="rank 6";} else {$rank="rank 7";} $_GET['u'] = abs((int) $_GET['u']); if(!$_GET['u']) { print "Invalid use of file"; } else { $q=$db->query("SELECT u.*,us.*,c.*,h.*,g.*,f.* FROM users u LEFT JOIN userstats us ON u.userid=us.userid LEFT JOIN cities c ON u.location=c.cityid LEFT JOIN houses h ON u.maxwill=h.hWILL LEFT JOIN gangs g ON g.gangID=u.gang LEFT JOIN fedjail f ON f.fed_userid=u.userid WHERE u.userid={$_GET['u']}"); if($db->num_rows($q) == 0) { print "Sorry, we could not find a user with that ID, check your source."; } else { $r=$db->fetch_row($q); if($r['user_level'] == 1) { $userl="Member"; } else if($r['user_level'] == 2) { $userl="Admin"; } else if ($r['user_level'] == 3) { $userl="Secretary"; } else if($r['user_level'] == 0) { $userl="NPC"; } else {$userl="Assistant"; } $lon=($r['laston'] > 0) ?date('F j, Y g:i:s a',$r['laston']) : "Never"; $sup=date('F j, Y g:i:s a',$r['signedup']); $ts=$r['strength']+$r['agility']+$r['guard']+$r['labour']+$r['IQ']; $d=""; if($r['laston'] > 0) { $la=time()-$r['laston']; $unit="seconds"; if($la >= 60) { $la=(int) ($la/60); $unit="minutes"; } if($la >= 60) { $la=(int) ($la/60); $unit="hours"; if($la >= 24) { $la=(int) ($la/24); $unit="days"; } } $str="$la $unit ago"; } else { $str="--"; } if($r['last_login'] > 0) { $ll=time()-$r['last_login']; $unit2="seconds"; if($ll >= 60) { $ll=(int) ($ll/60); $unit2="minutes"; } if($ll >= 60) { $ll=(int) ($ll/60); $unit2="hours"; if($ll >= 24) { $ll=(int) ($ll/24); $unit2="days"; } } $str2="$ll $unit2 ago"; } else { $str2="--"; } if($r['donatordays']) { $r['username'] = "<font color=red>{$r['username']}</font>";$d="<img src='donator.gif' alt='Donator: {$r['donatordays']} Days Left' title='Donator: {$r['donatordays']} Days Left' />"; } if($r['laston'] >= time()-15*60) { $on="<font color=green><b>Online</b></font>"; } else { $on="<font color=red><b>Offline</b></font>"; } print "<h3>Profile for {$r['username']}</h3> <table width=100% cellspacing=1 class='table'><tr style='background:gray'><th>General Info</th><th>Financial Info</th> <th>Display Pic</th></tr> <tr><td>Name: {$r['username']} [{$r['userid']}] $d<br /> User Level: $userl<br /> Duties: {$r['duties']}<br /> Gender: {$r['gender']}<br /> Signed Up: $sup<br /> Last Active: $lon<br /> Last Action: $str<br /> Last Login: $str2<br /> Online: $on<br /> Days Old: {$r['daysold']}<br /> Location: {$r['cityname']}</td><td> Money: \${$r['money']}<br /> Crystals: {$r['crystals']}<br /> Property: {$r['hNAME']}<br /> Referals: "; $rr=$db->query("SELECT * FROM referals WHERE refREFER={$r['userid']}"); print $db->num_rows($rr); print "<br /> Friends: {$r['friend_count']}<br /> Enemies: {$r['enemy_count']} </td> <td>"; if($r['display_pic']) { print "<img src='{$r['display_pic']}' width='150' height='150' alt='User Display Pic' title='User Display Pic' />"; } else { print "This user has no display pic!"; } $sh=($ir['user_level'] >1) ? "Staff Info" : "*"; print "</td></tr> <tr style='background:gray'><th>Physical Info</th><th>Links</th><th>$sh</th></tr> <tr><td>Level: {$r['level']}<br /> Rank: $rank <br /> <br /> Health: {$r['hp']}/{$r['maxhp']}<br /> Clan: "; if($r['gang']) { print "<a href='gangs.php?action=view&ID={$r['gang']}'>{$r['gangNAME']}</a>"; } else { print "N/A"; } if($r['fedjail']) { print "<br /><b><font color=red>In federal jail for {$r['fed_days']} day(s).<br /> {$r['fed_reason']}</font>"; } if($r['hospital']) { print "<br /><b><font color=red>In hospital for {$r['hospital']} minutes.<br />{$r['hospreason']}</font></b>"; } if($r['jail']) { print "<br /><b><font color=red>In jail for {$r['jail']} minutes.<br />{$r['jail_reason']}</font></b>"; } print "</td><td>[<a href='mailbox.php?action=compose&ID={$r['userid']}'>Send Mail</a>]<br /><br /> [<a href='sendcash.php?ID={$r['userid']}'>Send Cash</a>]<br /><br />"; if($set['sendcrys_on']) { print "[<a href='sendcrys.php?ID={$r['userid']}'>Send Crystals</a>]<br /><br />"; } if($set['sendbank_on']) { if($ir['bankmoney'] >= 0 && $r['bankmoney'] >= 0) { print "[<a href='sendbank.php?ID={$r['userid']}'>Bank Xfer</a>]<br /><br />"; } if($ir['cybermoney'] >= 0 && $r['cybermoney'] >= 0) { print "[<a href='sendcyber.php?ID={$r['userid']}'>CyberBank Xfer</a>]<br /><br />"; } } print " [<a href='attack.php?ID={$r['userid']}'>Attack</a>]<br /><br /> [<a href='contactlist.php?action=add&ID={$r['userid']}'>Add Contact</a>]"; if($ir['user_level'] == 2 || $ir['user_level'] == 3 || $ir['user_level'] == 5) { print "<br /><br /> [<a href='jailuser.php?userid={$r['userid']}'>Jail</a>]<br /><br /> [<a href='mailban.php?userid={$r['userid']}'>MailBan</a>]"; } if($ir['donatordays'] > 0) { print "<br /><br /> [<a href='friendslist.php?action=add&ID={$r['userid']}'>Add Friends</a>]<br /><br /> [<a href='blacklist.php?action=add&ID={$r['userid']}'>Add Enemies</a>]<br />"; } print "</td><td>"; if($ir['user_level'] == 2 || $ir['user_level'] == 3 || $ir['user_level'] == 5) { $r['lastiph']=@gethostbyaddr($r['lastip']); $r['lastiph']=checkblank($r['lastiph']); $r['lastip_loginh']=@gethostbyaddr($r['lastip_login']); $r['lastip_loginh']=checkblank($r['lastip_loginh']); $r['lastip_signuph']=@gethostbyaddr($r['lastip_signup']); $r['lastip_signuph']=checkblank($r['lastip_signuph']); print "<h3>Internet Info</h3><table width='100%' border='0' cellspacing='1' class='table'> <tr><td></td><td class='h'>IP</td><td class='h'>Hostname</td></tr> <tr><td class='h'>Last Hit</td><td>$r[lastip]</td><td>$r[lastiph]</td></tr> <tr><td class='h'>Last Login</td><td>$r[lastip_login]</td><td>$r[lastip_loginh]</td></tr> <tr><td class='h'>Signup</td><td>$r[lastip_signup]</td><td>$r[lastip_signuph]</td></tr></table>"; print "<form action='staffnotes.php' method='post'> Staff Notes: <br /> <textarea rows=7 cols=40 name='staffnotes'>{$r['staffnotes']}</textarea> <br /><input type='hidden' name='ID' value='{$_GET['u']}' /> <input type='submit' value='Change' /></form>"; } else { print "*"; } print "</tr></table>"; } } function checkblank($in) { if(!$in) { return "N/A"; } return $in; } $h->endpage(); ?> Correct, you've put it in the wrong place. $r hasn't been declared, yet. Put the rank 'mod' below line 25. Quote
cjelliott Posted January 10, 2013 Posted January 10, 2013 Correct, you've put it in the wrong place. $r hasn't been declared, yet. Put the rank 'mod' below line 25. cant believe i didnt notice that xD thanks alot really helped Quote
cjelliott Posted January 11, 2013 Posted January 11, 2013 where would i put the code if i wanted it displayed on the index page? im guessing the code would be $ir not $r? or am i wrong? heres my index .php page <?php $housequery=1; include "globals.php"; print "<h3>General Info:</h2>"; $exp=(int)($ir['exp']/$ir['exp_needed']*100); print "<table><tr><td><b>Name:</b> {$ir['username']}</td><td><b>Crystals:</b> {$cm}</td></tr><tr> <td><b>Level:</b> {$ir['level']}</td> <td> <b>Rank:</b> $rank </tr><tr> <td><b>Exp:</b> {$exp}%</td> <td><b>Money:</b> $fm</td> </tr><tr> <td><b>HP:</b> {$ir['hp']}/{$ir['maxhp']} <td><b>Property:</b> {$ir['hNAME']}</tr></table>"; print "<hr><h3>Stats Info:</h3>"; $ts=$ir['strength']+$ir['agility']+$ir['guard']+$ir['labour']+$ir['IQ']; $ir['strank']=get_rank($ir['strength'],'strength'); $ir['agirank']=get_rank($ir['agility'],'agility'); $ir['guarank']=get_rank($ir['guard'],'guard'); $ir['labrank']=get_rank($ir['labour'],'labour'); $ir['IQrank']=get_rank($ir['IQ'],'IQ'); $tsrank=get_rank($ts,'strength+agility+guard+labour+IQ'); $ir['strength']=number_format($ir['strength']); $ir['agility']=number_format($ir['agility']); $ir['guard']=number_format($ir['guard']); $ir['labour']=number_format($ir['labour']); $ir['IQ']=number_format($ir['IQ']); $ts=number_format($ts); print "<table><tr><td><b>Strength:</b> {$ir['strength']} [Ranked: {$ir['strank']}]</td><td><b>Agility:</b> {$ir['agility']} [Ranked: {$ir['agirank']}]</td></tr> <tr><td><b>Guard:</b> {$ir['guard']} [Ranked: {$ir['guarank']}]</td><td><b>Labour:</b> {$ir['labour']} [Ranked: {$ir['labrank']}]</td></tr> <tr><td><b>IQ: </b> {$ir['IQ']} [Ranked: {$ir['IQrank']}]</td><td><b>Total stats:</b> {$ts} [Ranked: $tsrank]</td></tr></table>"; if(isset($_POST['pn_update'])) { $db->query("UPDATE users SET user_notepad='{$_POST['pn_update']}' WHERE userid=$userid"); $ir['user_notepad']=stripslashes($_POST['pn_update']); print "<hr><b>Personal Notepad Updated!</b>"; } print "<hr>Your Personal Notepad:<form action='index.php' method='post'> <textarea rows='10' cols='50' name='pn_update'>".htmlspecialchars($ir['user_notepad'])."</textarea><br /> <input type='submit' value='Update Notes' /></form>"; $h->endpage(); ?> Quote
sniko Posted January 11, 2013 Posted January 11, 2013 where would i put the code if i wanted it displayed on the index page? im guessing the code would be $ir not $r? or am i wrong? heres my index .php page <?php $housequery=1; include "globals.php"; print "<h3>General Info:</h2>"; $exp=(int)($ir['exp']/$ir['exp_needed']*100); print "<table><tr><td><b>Name:</b> {$ir['username']}</td><td><b>Crystals:</b> {$cm}</td></tr><tr> <td><b>Level:</b> {$ir['level']}</td> <td> <b>Rank:</b> $rank </tr><tr> <td><b>Exp:</b> {$exp}%</td> <td><b>Money:</b> $fm</td> </tr><tr> <td><b>HP:</b> {$ir['hp']}/{$ir['maxhp']} <td><b>Property:</b> {$ir['hNAME']}</tr></table>"; print "<hr><h3>Stats Info:</h3>"; $ts=$ir['strength']+$ir['agility']+$ir['guard']+$ir['labour']+$ir['IQ']; $ir['strank']=get_rank($ir['strength'],'strength'); $ir['agirank']=get_rank($ir['agility'],'agility'); $ir['guarank']=get_rank($ir['guard'],'guard'); $ir['labrank']=get_rank($ir['labour'],'labour'); $ir['IQrank']=get_rank($ir['IQ'],'IQ'); $tsrank=get_rank($ts,'strength+agility+guard+labour+IQ'); $ir['strength']=number_format($ir['strength']); $ir['agility']=number_format($ir['agility']); $ir['guard']=number_format($ir['guard']); $ir['labour']=number_format($ir['labour']); $ir['IQ']=number_format($ir['IQ']); $ts=number_format($ts); print "<table><tr><td><b>Strength:</b> {$ir['strength']} [Ranked: {$ir['strank']}]</td><td><b>Agility:</b> {$ir['agility']} [Ranked: {$ir['agirank']}]</td></tr> <tr><td><b>Guard:</b> {$ir['guard']} [Ranked: {$ir['guarank']}]</td><td><b>Labour:</b> {$ir['labour']} [Ranked: {$ir['labrank']}]</td></tr> <tr><td><b>IQ: </b> {$ir['IQ']} [Ranked: {$ir['IQrank']}]</td><td><b>Total stats:</b> {$ts} [Ranked: $tsrank]</td></tr></table>"; if(isset($_POST['pn_update'])) { $db->query("UPDATE users SET user_notepad='{$_POST['pn_update']}' WHERE userid=$userid"); $ir['user_notepad']=stripslashes($_POST['pn_update']); print "<hr><b>Personal Notepad Updated!</b>"; } print "<hr>Your Personal Notepad:<form action='index.php' method='post'> <textarea rows='10' cols='50' name='pn_update'>".htmlspecialchars($ir['user_notepad'])."</textarea><br /> <input type='submit' value='Update Notes' /></form>"; $h->endpage(); ?> Below line 3, as in globals $ir has already been defined ;) Quote
KyleMassacre Posted January 11, 2013 Posted January 11, 2013 didnt work for me tho not many codes seem to be working for me lately any1 know why this wont work? if ($r['level'] < 10) {$rank="rank 1";} else if ($r['level'] < 25) {$rank="rank 2";} else if ($r['level'] < 50) {$rank="rank 3";} else if ($r['level'] < 100) {$rank="rank 4";} else if ($r['level'] < 250) {$rank="rank 5";} else if ($r['level'] < 1000) {$rank="rank 6";} else {$rank="rank 7";} im on v2 if u any1 gets this to work or knows whats wrong with it please tell me how to fix it thanks ps i got a feeling its just that ive placed the code in the wrong place within viewuser.php For the game ranks funcs, you didnt copy and paste what was in the code box did you? Cause line numbers one and two in there wont help it to work at all. Just copy it from line 4 down Quote
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.