Kaeliah
10-14-2010, 08:36 PM
Adoptable Pet Status Mod
Mod by Kaeliah
Description
Adds another dimension into the Adoptables Script by letting adoptables get sick! You can choose the chance each adoptable type has of getting sick every time it's clicked. If an adoptable gets sick, it can be cured by its owner by clicking on it. Of course you can edit this if you have an item/cash mod or anything along those lines. You can also feel free to add other status issues other than just Happy and Sick and this mod would be a perfect start for those popular Pokemon games. There is a lot you can do with this mod! My only request is you share what you've done with the mod!!
Possible Future Features:
Edit chance of getting sick from Admin panel
Directions For Installation
-MySQL Databases
In table 'adoptables' add another field:
Field | Type | Null | Default |
========================================|
sickchance | int(11) | Yes | NULL |
========================================|
In table 'owned_adoptables add another field:
Field | Type | Collation | Null | Default |
================================================== ============|
status | varchar(20) | utf8_general_ci | No | Happy |
================================================== ============|
-Code Editing
In levelup.php
Find:
$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");
$usealternates2=@mysql_result($result,$i,"usealternates2");
$isfrozen=@mysql_result($result,$i,"isfrozen");
$owner=@mysql_result($result,$i,"owner");
Add After:
$petstatus=@mysql_result($result,$i,"status");
Find:
if($isfrozen == "yes"){
$article_title = $lang_isfrozen_title;
$article_content = $lang_isfrozen_explain;
}
Add After:
else if($petstatus != "Happy" and $loggedinname != $owner){
$article_title = "Cannot Level Up";
$article_content = "This pet is not happy, only happy pets can be leveled up!";
}
Find:
// Now we need to update our vote_voters table with the user's vote...
mysql_query("INSERT INTO ".$prefix."vote_voters VALUES ('$date', '$loggedinname', '$ip','$id')");
Add After:
// By leveling up this adoptable, there's a chance that it will get sick!
if($loggedinname == $owner and $petstatus != "Happy") {
$petstatus = "Happy";
$query2 = "UPDATE ".$prefix."owned_adoptables SET status='".$petstatus."' WHERE aid='".$id."'";
mysql_query($query2);
}
$query2 = "SELECT * FROM ".$prefix."adoptables WHERE type='$type'";
$result2 = mysql_query($query2);
$num2 = mysql_numrows($result2);
//Loop out code
$i=0;
while ($i < 1) {
$sickchance=@mysql_result($result2,$i,"sickchance");
$i++;
}
if($sickchance != 0) {
$randnum = rand(1, $sickchance);
if($randnum == 1){
$petstatus = "Sick";
$query2 = "UPDATE ".$prefix."owned_adoptables SET status='".$petstatus."' WHERE aid='".$id."'";
mysql_query($query2);
}
}
In admin.php
Find:
<p>
<input type='submit' name='Submit' value='Create This Adoptable'>
</p>
<p> </p>
</form>";
} //End the create a new adoptable form
Add BEFORE:
<hr>
<p><strong>Status Settings</strong></p>
<p>
<input name='sickchance' type='text' id='sickchance' size='6' maxlength='6'><br>
This type of pet has a 1 in _____ chance of getting sick everytime it is clicked.<br>
This number should probably be higher as only the owner of the pet will be able to cure it.<br>
Leave blank or input 0 to have no chance of getting sick.<br>
</p>
In nadopt.php
Find:
$altchance = $_POST["altchance"];
$altchance = secure($altchance);
Add After:
$sickchance = $_POST["sickchance"];
$sickchance = secure($sickchance);
Find:
mysql_query("INSERT INTO ".$prefix."adoptables VALUES ('', '$name', '$description','$eggimage','$cba','$promocode', '$freqcond', '$number','$datecond','$date','$adoptscond','$maxn umcond','$morethannum','$usergroupcond','$usergrou ps','$alternates','$altoutlevel','$altchance')");
Replace with:
if($sickchance == ""){
$sickchance = 0; }
mysql_query("INSERT INTO ".$prefix."adoptables VALUES ('', '$name', '$description','$eggimage','$cba','$promocode', '$freqcond', '$number','$datecond','$date','$adoptscond','$maxn umcond','$morethannum','$usergroupcond','$usergrou ps','$alternates','$altoutlevel','$altchance','$si ckchance')");
In doadopt.php
(Thank you HOF for pointing this out. ^.^)
FIND
mysql_query("INSERT INTO ".$prefix."owned_adoptables VALUES ('', '$type', '$name','$loggedinname','0','0', '$code', '','$alts','notfortrade','no')");
Replace With:
mysql_query("INSERT INTO ".$prefix."owned_adoptables VALUES ('', '$type', '$name','$loggedinname','0','0', '$code', '','$alts','notfortrade','no','Happy')");
Optional
It's probably a good idea to show the status of the pet somewhere. This will add the pet's status to the main manage panel. (Click on my adoptables then click on the adoptable and you'll be able to see the status)
In myadopts.php
Find:
$aid=@mysql_result($result,$i,"aid"); //The adoptable's ID
$currentlevel=@mysql_result($result,$i,"currentlevel");
$type=@mysql_result($result,$i,"type");
$name=@mysql_result($result,$i,"name");
Add after:
$petstatus=@mysql_result($result,$i,"status");
Find:
<b><a href='levelup.php?id=".$id."'><img src='templates/icons/add.gif' border=0> Level Up ".$name."</a><br>
Add BEFORE:
<b><u>Status:</b></u> ".$petstatus."<br>
That's everything for now.
Mod by Kaeliah
Description
Adds another dimension into the Adoptables Script by letting adoptables get sick! You can choose the chance each adoptable type has of getting sick every time it's clicked. If an adoptable gets sick, it can be cured by its owner by clicking on it. Of course you can edit this if you have an item/cash mod or anything along those lines. You can also feel free to add other status issues other than just Happy and Sick and this mod would be a perfect start for those popular Pokemon games. There is a lot you can do with this mod! My only request is you share what you've done with the mod!!
Possible Future Features:
Edit chance of getting sick from Admin panel
Directions For Installation
-MySQL Databases
In table 'adoptables' add another field:
Field | Type | Null | Default |
========================================|
sickchance | int(11) | Yes | NULL |
========================================|
In table 'owned_adoptables add another field:
Field | Type | Collation | Null | Default |
================================================== ============|
status | varchar(20) | utf8_general_ci | No | Happy |
================================================== ============|
-Code Editing
In levelup.php
Find:
$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");
$usealternates2=@mysql_result($result,$i,"usealternates2");
$isfrozen=@mysql_result($result,$i,"isfrozen");
$owner=@mysql_result($result,$i,"owner");
Add After:
$petstatus=@mysql_result($result,$i,"status");
Find:
if($isfrozen == "yes"){
$article_title = $lang_isfrozen_title;
$article_content = $lang_isfrozen_explain;
}
Add After:
else if($petstatus != "Happy" and $loggedinname != $owner){
$article_title = "Cannot Level Up";
$article_content = "This pet is not happy, only happy pets can be leveled up!";
}
Find:
// Now we need to update our vote_voters table with the user's vote...
mysql_query("INSERT INTO ".$prefix."vote_voters VALUES ('$date', '$loggedinname', '$ip','$id')");
Add After:
// By leveling up this adoptable, there's a chance that it will get sick!
if($loggedinname == $owner and $petstatus != "Happy") {
$petstatus = "Happy";
$query2 = "UPDATE ".$prefix."owned_adoptables SET status='".$petstatus."' WHERE aid='".$id."'";
mysql_query($query2);
}
$query2 = "SELECT * FROM ".$prefix."adoptables WHERE type='$type'";
$result2 = mysql_query($query2);
$num2 = mysql_numrows($result2);
//Loop out code
$i=0;
while ($i < 1) {
$sickchance=@mysql_result($result2,$i,"sickchance");
$i++;
}
if($sickchance != 0) {
$randnum = rand(1, $sickchance);
if($randnum == 1){
$petstatus = "Sick";
$query2 = "UPDATE ".$prefix."owned_adoptables SET status='".$petstatus."' WHERE aid='".$id."'";
mysql_query($query2);
}
}
In admin.php
Find:
<p>
<input type='submit' name='Submit' value='Create This Adoptable'>
</p>
<p> </p>
</form>";
} //End the create a new adoptable form
Add BEFORE:
<hr>
<p><strong>Status Settings</strong></p>
<p>
<input name='sickchance' type='text' id='sickchance' size='6' maxlength='6'><br>
This type of pet has a 1 in _____ chance of getting sick everytime it is clicked.<br>
This number should probably be higher as only the owner of the pet will be able to cure it.<br>
Leave blank or input 0 to have no chance of getting sick.<br>
</p>
In nadopt.php
Find:
$altchance = $_POST["altchance"];
$altchance = secure($altchance);
Add After:
$sickchance = $_POST["sickchance"];
$sickchance = secure($sickchance);
Find:
mysql_query("INSERT INTO ".$prefix."adoptables VALUES ('', '$name', '$description','$eggimage','$cba','$promocode', '$freqcond', '$number','$datecond','$date','$adoptscond','$maxn umcond','$morethannum','$usergroupcond','$usergrou ps','$alternates','$altoutlevel','$altchance')");
Replace with:
if($sickchance == ""){
$sickchance = 0; }
mysql_query("INSERT INTO ".$prefix."adoptables VALUES ('', '$name', '$description','$eggimage','$cba','$promocode', '$freqcond', '$number','$datecond','$date','$adoptscond','$maxn umcond','$morethannum','$usergroupcond','$usergrou ps','$alternates','$altoutlevel','$altchance','$si ckchance')");
In doadopt.php
(Thank you HOF for pointing this out. ^.^)
FIND
mysql_query("INSERT INTO ".$prefix."owned_adoptables VALUES ('', '$type', '$name','$loggedinname','0','0', '$code', '','$alts','notfortrade','no')");
Replace With:
mysql_query("INSERT INTO ".$prefix."owned_adoptables VALUES ('', '$type', '$name','$loggedinname','0','0', '$code', '','$alts','notfortrade','no','Happy')");
Optional
It's probably a good idea to show the status of the pet somewhere. This will add the pet's status to the main manage panel. (Click on my adoptables then click on the adoptable and you'll be able to see the status)
In myadopts.php
Find:
$aid=@mysql_result($result,$i,"aid"); //The adoptable's ID
$currentlevel=@mysql_result($result,$i,"currentlevel");
$type=@mysql_result($result,$i,"type");
$name=@mysql_result($result,$i,"name");
Add after:
$petstatus=@mysql_result($result,$i,"status");
Find:
<b><a href='levelup.php?id=".$id."'><img src='templates/icons/add.gif' border=0> Level Up ".$name."</a><br>
Add BEFORE:
<b><u>Status:</b></u> ".$petstatus."<br>
That's everything for now.