View Single Post
  #3  
Old 01-27-2009, 04:57 PM
BMR777 BMR777 is offline
Member
 
Join Date: Jan 2011
Posts: 1,122
Gender: Male
Credits: 16,730
BMR777 is on a distinguished road
Default RE: level up to 100!

Sorry about the delay, sometimes you've got to be a little patient though. I check these forums daily though as I am a full time college student I'm not on until afternoon time. :)

Anyway, to the issue at hand, the file levelup.php handles the actual calculation of how to do a level up for a creature. If you want to see the code, it starts after this line:

PHP Code:
//Begin the level up procedure 
The level up procedure is similar, but not identical for both registered users and guests.

Here's the actual code that does the level up for logged in users:

PHP Code:
$query "SELECT * FROM owned_adoptables WHERE uid = '$id'";
            
$result = @mysql_query($query);
            
$num = @mysql_numrows($result);

            
//Loop out code
            
$i=0;
            while (
$i 1) {

            
$name=@mysql_result($result,$i,"name");
            
$imageurl=@mysql_result($result,$i,"imageurl");
            
$currentlevel=@mysql_result($result,$i,"currentlevel");
            
$totalclicks=@mysql_result($result,$i,"totalclicks");
            
$type=@mysql_result($result,$i,"type");

            
$i++;
            }

            
$plus1 $totalclicks 1;
            
mysql_query("UPDATE owned_adoptables SET totalclicks='".$plus1."' WHERE uid='".$id."'");    

            
//Check and see if we need a level up...
            
$levelup checklevel($totalclicks);
            if(
$levelup $currentlevel){
            
//The creature needs to level up
            //Check if we are at max level

            
$query "SELECT * FROM adoptable_rankimages WHERE name = '$type'";
            
$result = @mysql_query($query);
            
$num = @mysql_numrows($result);

            
//Loop out code
            
$i=0;
            while (
$i 1) {

            
$l1i=@mysql_result($result,$i,"l1i");
            
$l2i=@mysql_result($result,$i,"l2i");
            
$l3i=@mysql_result($result,$i,"l3i");
            
$l4i=@mysql_result($result,$i,"l4i");
            
$l5i=@mysql_result($result,$i,"l5i");    
            
$l6i=@mysql_result($result,$i,"l6i");
            
$l7i=@mysql_result($result,$i,"l7i");
            
$l8i=@mysql_result($result,$i,"l8i");
        

            
$i++;
            }
            
            
$mymax 8;
            if(
$l1i == "" || l1i == NULL){
            
$mymax 0;
            
$img $l1i;
            }    
            else if(
$l2i == "" || l2i == NULL){
            
$mymax 1;
            
$img $l2i;
            }
            else if(
$l3i == "" || l3i == NULL){
            
$mymax 2;
            
$img $l3i;
            }
            else if(
$l4i == "" || l4i == NULL){
            
$mymax 3;
            
$img $l4i;
            }
            else if(
$l5i == "" || l5i == NULL){
            
$mymax 4;
            
$img $l5i;
            }
            else if(
$l6i == "" || l6i == NULL){
            
$mymax 5;
            
$img $l6i;
            }
            else if(
$l7i == "" || l7i == NULL){
            
$mymax 6;
            
$img $l7i;
            }
            else if(
$l8i == "" || l8i == NULL){
            
$mymax 7;
            
$img $l8i;
            }


            if(
$currentlevel $mymax){
            
//Not at max level, rank them up
    
            
if($levelup == "1" and $mymax >= $levelup){
            
$img $l1i;
            }        
            if(
$levelup == "2" and $mymax >= $levelup){
            
$img $l2i;
            }
            if(
$levelup == "3" and $mymax >= $levelup){
            
$img $l3i;
            }
            if(
$levelup == "4" and $mymax >= $levelup){
            
$img $l4i;
            }
            if(
$levelup == "5" and $mymax >= $levelup){
            
$img $l5i;
            }
            if(
$levelup == "6" and $mymax >= $levelup){
            
$img $l6i;
            }
            if(
$levelup == "7" and $mymax >= $levelup){
            
$img $l7i;
            }
            if(
$levelup == "8" and $mymax >= $levelup){
            
$img $l8i;
            }

            
mysql_query("UPDATE owned_adoptables SET currentlevel='".$levelup."' WHERE uid='".$id."'");
            
mysql_query("UPDATE owned_adoptables SET imageurl='".$img."' WHERE uid='".$id."'");
            
$flag 1;
            
$currentlevel $levelup;
            }


            } 
The number of levels is hard-coded into the script. I am assuming though you want to be able to have 100 separate images for a creature? That would be possible by editing the level up code, the database table structure and the levelup.php file to accommodate more images, but having that many images there could be sloppy and tedious.

BMR777
Reply With Quote