User Points & Ranks/Levels

Forum
Last Post
Threads / Messages

Sasoragon

Beginniner Coder :D
Member
Joined
Jan 15, 2011
Messages
29
Points
0
Age
27
Location
In the Myadopts Support Forums
Mysidian Dollar
4,191
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. :meow:

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 :colonu:

Find the code that looks somewhat like this: (Mine will probably be a little different than yours)

PHP:
//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. :happycbig:

Now find where it says:

PHP:
                  // 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:
                  // 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. :el:

(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. :jay: )

After that, open up profile.php.

Find where is says this:

PHP:
	$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:
        $points=@mysql_result($result,$i,"points");

Now scroll down and find where it says this:

PHP:
	$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:
        // 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:
        <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. :ti:
 
I don't know why I haven't thought of this yet.
This is awesome!
 
This looks really nice Sasoragon, glad to see you are making quality PHP scripts now. ^^ Keep this up and you may receive Premium Membership soon.
 
D'aww, thanks Fadill, Hoffie. :smile:

This idea randomly popped into my head when I was (supposed to be) studying yesterday. I thought it would make a cool feature, so I decided to test out coding it. :colonu:
 
D'aww, thanks Fadill, Hoffie. :smile:

This idea randomly popped into my head when I was (supposed to be) studying yesterday. I thought it would make a cool feature, so I decided to test out coding it. :colonu:

EDIT: Gah, my post was posted twice. Since I can't find the delete button, could a mod please delete this post? :p

Just hit Edit, then Delete. :3

Nice mod, I'll use it, if I can find a possible use for it on my site. xD

/shot
 
Gigi - GREAT MINDS THINK ALIKE? :angrygrin:

And yus, thanks TCK. I managed to delete it. :jay:

Sensa - I don't quite understand what you mean. The points are obtained by clicking adoptables. :3
 
how to have the point obtained is for the owner of adoptable

I wouldn't like that. Then some people would make their adoptable give someone 1 point and then another adoptable they might make it 7 points. Plus that's a bit too much customization for your adopts to me.
 
I wouldn't like that. Then some people would make their adoptable give someone 1 point and then another adoptable they might make it 7 points. Plus that's a bit too much customization for your adopts to me.

with a simple program you get all possible experience, that's why I liked that the clicker earn points, but in the end and solve it ^ ^
 
@SASO-OF COURSE, THIS HAS BEEN PROVE ALREADY :madnoes: MAYBE OUR SIGS HERE SHOULD--Naw, MA sig is enough :OHSHITALION: GO PINEAPPLE AND HAVE FUN CODING STUFF :colonu:
 
YAY smile
This is going to be very helpful to me in the future. ^^ I would love if you could also explain how to give users points by logging in such. :9 Ilu~
 

Similar threads

Users who are viewing this thread

  • Forum Contains New Posts
  • Forum Contains No New Posts

Forum statistics

Threads
4,267
Messages
33,048
Members
1,602
Latest member
BerrieMilk
BETA

Latest Threads

Latest Posts

Top