X Days before evolution
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 Code:
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 Code:
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 Code:
$timeevolve = time();
3. Open your levelup.php
Go to the first loop out code and find
PHP Code:
$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 Code:
$timeevolve=@mysql_result($result,$i,"timeevolve");
So now your loop out code should look something like this
PHP Code:
$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 Code:
if($timeevolve == 0){ $newtime = time(); mysql_query("UPDATE ".prefix."owned_adoptables SET timeevolve = '$newtime' WHERE aid='$id'"); }
Now find this code
PHP Code:
$requiredclicks=@mysql_result($result,$i,"requiredclicks"); // The number of clicks required for the next level
Add above
PHP Code:
$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 Code:
$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 Code:
} // End the if statement if we are leveling the adoptable up
Add a closing curly bracket below that
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 by fadillzzz; 02-22-2011 at 05:18 AM.
|