User points and Ranks~
This mod will give users another form of "points" to collect. The more points you have, the higher your User Rank will be. Points can be collected by leveling your own or other people's adoptables.
First, enter the MySQL Database. Under "_users", add another column at the bottom that looks like this:
Code:
Field: Type: Null:
points int(20) Yes
Now. Go to
register.php
Find the code that looks somewhat like this: (Mine will probably be a little different than yours)
PHP Code:
//All checks are done, actually create the user's account on the database
$date = date('Y-m-d');
mysql_query("INSERT INTO ".$prefix."users VALUES ('', '$username', '$pass1','$email','3','1', '$date', '0','','','','','','500','100','','','','','Unknown')");
//Now that we have created the user, let's log them in...
$status = dologin($username, $pass1);
Well, at the end of the INSERT INTO mysql_query, add another
,'50' at the end of it. (On mine it would be behind the 'Unknown'.)
Once you've changed that, go to
levelup.php.
Now find where it says:
PHP Code:
// Start Rewards
// ************************************************
//Get currency on level up
$query = "SELECT * FROM `adopts_users` WHERE `username`='$loggedinname'";
$result = mysql_query($query);
$num = mysql_numrows($result);
$i = 0;
while ($i < 1) {
$dollar = @mysql_result($result, $i, "dollar");
// Change this number 10 to the number of currency you want users to earn on level up
$amount = rand(5,15);
$newbalance = $dollar + $amount;
$i++;
}
mysql_query("UPDATE `adopts_users` SET `dollar`='" . $newbalance . "' WHERE `username`='$loggedinname'");
$article_content = $article_content . "<div align='center'><br />You have earned ". $amount ." Dollars for leveling up this Adoptable. <br />You now have " . $newbalance . " Dollars.</div>";
}
Replace all of that with this:
PHP Code:
// Start Rewards
// ************************************************
//Get currency on level up
$query = "SELECT * FROM `adopts_users` WHERE `username`='$loggedinname'";
$result = mysql_query($query);
$num = mysql_numrows($result);
$i = 0;
while ($i < 1) {
$dollar = @mysql_result($result, $i, "dollar");
$points = @mysql_result($result, $i, "points");
// Change this number 10 to the number of currency you want users to earn on level up
$amount = rand(5, 15);
$pointamount = rand(5, 15);
$newbalance = $dollar + $amount;
$newpointbalance = $points + $pointamount;
$i++;
}
mysql_query("UPDATE `adopts_users` SET `dollar`='" . $newbalance . "' WHERE `username`='$loggedinname'");
mysql_query("UPDATE `adopts_users` SET `points`='" . $newpointbalance . "' WHERE `username`='$loggedinname'");
$article_content = $article_content . "<div align='center'><br />You have earned ". $amount ." Dollars and ".$pointamount." Points for leveling up this Adoptable. <br />You now have " . $newbalance . " Dollars and ".$newpointbalance." Points.</div>";
}
That way, people will earn points as well when leveling up an adoptable.
(You can also make it so that users earn points by logging in, posting in the shoutbox, viewing pages, when sending PM's, etc. Maybe later I'll add to this profile saying how to add those stuff as well.
)
After that, open up
profile.php.
Find where is says this:
PHP Code:
$i=0;
while ($i < 1) {
$usersname=@mysql_result($result,$i,"username");
$usersgroup=@mysql_result($result,$i,"usergroup");
$website=@mysql_result($result,$i,"website");
$aim=@mysql_result($result,$i,"aim");
$yahoo=@mysql_result($result,$i,"yahoo");
$msn=@mysql_result($result,$i,"msn");
$membersince=@mysql_result($result,$i,"membersince");
Add this to the bottom of it:
PHP Code:
$points=@mysql_result($result,$i,"points");
Now scroll down and find where it says this:
PHP Code:
$article_title = $userdisp."'s Profile:";
$article_content = "<b><u>".$lang_basic_info."".$usersname.":</u></b><br><br>
<img src='templates/icons/web.gif'> ".$website."<br>
<img src='templates/icons/aim.gif'> ".$aim."<br>
<img src='templates/icons/msn.gif'> ".$msn."<br>
<img src='templates/icons/yahoo.gif'> ".$yahoo."<br>
<img src='templates/icons/title.gif'> <a href='messages.php?act=newpm&user=".$usersname."'>Send ".$usersname." a Private Message</a><br>
<br><b><u>".$usersname."'s Stats:</b></u><br><br>
<b>Member Since:</b> ".$membersince."<br>
<b>Number Of Pets Owned:</b> ".$numpets."<br>
<b><u>".$usersname."'s Pets:</u></b><br><br>";
Directly above that, paste this:
PHP Code:
// Begin defining the user's Rank..
$rankval = 0;
$rank = -1;
while ($rankval < $points) {
$rankval = $rankval + 50;
// Change the + 50 to however many points you want the user to have before going up a rank.
$rank++;
}
Now go underneath
.$usersname.'s Stats (it's still under profile.php) and paste this in:
PHP Code:
<b>Amount of Points:</b> ".$points."<br>
<b>".$usersname."'s Rank:</b> ".$rank."<br><br>
Aaand... That's about it! This was my first Mod, so sorry about it not being a big one. Hopefully once I get better at PHP, my Mods will also get bigger and better.