X Days before evolution

Forum
Last Post
Threads / Messages

fadillzzz

Dev Staff
Staff member
Dev Staff
Joined
Jan 20, 2010
Messages
499
Points
0
Mysidian Dollar
25,250
This mod will prevent the evolution of adoptables until they've passed certain days.

Make a backup of your files before proceeding
1. Create new column in the owned_adoptables


Field name: timeevolve
Type: int
Length: 11
Null: No
Default: 0


2. Update the INSERT query in the doadopt.php & doadoptab.php

Open doadopt.php & doadoptab.php and find the INSERT query
It usually looks like this (Yours will probably a little longer)
PHP:
mysql_query("INSERT INTO ".$prefix."owned_adoptables VALUES ('', '$type', 'Telur Misterius','$loggedinname','0','0', '$code', '','$alts','fortrade','no')");
Add ,'$timeevolve' into the query so it will now look like this
PHP:
mysql_query("INSERT INTO ".$prefix."owned_adoptables VALUES ('',  '$type', 'Telur Misterius','$loggedinname','0','0', '$code',  '','$alts','fortrade','no','$timeevolve')");
And before the insert query add this
PHP:
$timeevolve = time();
3. Open your levelup.php

Go to the first loop out code and find
PHP:
    $aid=@mysql_result($result,$i,"aid");
    $type=@mysql_result($result,$i,"type"); 
    $name=@mysql_result($result,$i,"name");
    $totalclicks=@mysql_result($result,$i,"totalclicks");
    $currentlevel=@mysql_result($result,$i,"currentlevel"); 
    $usealternates=@mysql_result($result,$i,"usealternates");
    $isfrozen=@mysql_result($result,$i,"isfrozen");
    $owner=@mysql_result($result,$i,"owner");
Add below

PHP:
    $timeevolve=@mysql_result($result,$i,"timeevolve");
So now your loop out code should look something like this

PHP:
    $i=0;
    while ($i < 1) {
        $aid=@mysql_result($result,$i,"aid");
        $type=@mysql_result($result,$i,"type"); 
        $name=@mysql_result($result,$i,"name");
        $totalclicks=@mysql_result($result,$i,"totalclicks");
        $currentlevel=@mysql_result($result,$i,"currentlevel"); 
        $usealternates=@mysql_result($result,$i,"usealternates");
        $isfrozen=@mysql_result($result,$i,"isfrozen");
        $owner=@mysql_result($result,$i,"owner");
        $timeevolve=@mysql_result($result,$i,"timeevolve");
        $i++;
    }
Just below the loop out code, add

PHP:
    if($timeevolve == 0){
        $newtime = time();
        mysql_query("UPDATE ".prefix."owned_adoptables SET timeevolve = '$newtime' WHERE aid='$id'");
    }
Now find this code

PHP:
    $requiredclicks=@mysql_result($result,$i,"requiredclicks");  // The number of clicks required for the next level
Add above
PHP:
    $primaryimage=@mysql_result($result,$i,"primaryimage");
Add below (below $requiredclicks .... )
NOTE: From this code below, change the $evolveif variable to your liking.
(E.g: To wait 3 days before evolution, change it to time() - 3 * 24 * 60 * 60)

PHP:
    $query = "SELECT * FROM ".$prefix."levels WHERE adoptiename='$type' and thisislevel='$currentlevel'";
    $result = mysql_query($query);
    $num = mysql_num_rows($result);
    //Loop out code
    $i=0;
    while ($i < 1) {
        $oldprimaryimage=@mysql_result($result,$i,"primaryimage");
        $i++;
    }
    $evolveif = time() - 1 * 24 * 60 * 60; // (From right) 60 represent seconds, 60 represent minutes, 24 represent hours, 1 represent days
        if($oldprimaryimage != $primaryimage){
            if($timeevolve < $evolveif){

                // Check if the number of clicks we have now is greater than or equal to the required clicks to level up...

                if($newclicks >= $requiredclicks and $requiredclicks != 0 and $requiredclicks != ""){

                    // We need to level this adoptable up...

                    $query = "UPDATE ".$prefix."owned_adoptables SET currentlevel='".$nextlevel."' WHERE aid='".$id."'";
                    mysql_query($query);

                    // Now we check if we are enabling alternate images...
    
                    $parentid = converttypetoparentid($type); // Get the ID of the parent type adoptable
                    $altstatus = getaltstatus($parentid, $id, $nextlevel); // Check if we are using alternate images or not...

                    if($altstatus == "yes"){

                        // We are enabling alternate images for this adoptable...

                        $query = "UPDATE ".$prefix."owned_adoptables SET usealternates='yes' WHERE aid='".$id."'";
                        mysql_query($query);


                    }

                    // Now we can see if the adoptable's owner gets a reward...
                    // The reward function will take care of sending out any reward that exists...

                    $rewardstatus = reward($id, $type, $nextlevel, $owner);
                    mysql_query("UPDATE ".$prefix."owned_adoptables SET timeevolve = ".time()."  WHERE aid='".$id."'");
                }
            }

        }
Find this

PHP:
    } // End the if statement if we are leveling the adoptable up
Add a closing curly bracket below that

PHP:
    }
I've tested this and so far I've gotten any problems but in case this mod messed up your site, or it's not working at all, report it to me.
 
Last edited:

Similar threads

Users who are viewing this thread

  • Forum Contains New Posts
  • Forum Contains No New Posts

Forum statistics

Threads
4,274
Messages
33,114
Members
1,602
Latest member
BerrieMilk
BETA

Latest Threads

Latest Posts

Top