Hall of Famer |
09-16-2012 10:45 PM |
Well you can see a section of adoption form code in adopt.php like these:
PHP Code:
$article_content = $article_content."<br><img src='{$eggimage}' border='0'><br> <form name='form1' method='get' action='doadopt.php'> <p>Adoptable Name: <input name='name' type='text' id='name'> <input name='id' type='hidden' id='id' value='{$id}'> <input name='promocode' type='hidden' id='promocode' value='{$promocode}'> </p> <p> <input type='submit' name='Submit' value='Adopt Me'> </p>
You can add a new textfield called 'quantity' in this form section. You can place it anywhere above the submit line and below the form opening tag:
PHP Code:
<input name='number' type='text' id='number' value='1'>
Now you will need to go to doadopt.php and retrieve this number from $_GET array:
PHP Code:
$id = $_GET["id"]; $promocode = $_GET["promocode"]; $name = $_GET["name"];
Add below:
PHP Code:
$number = $_GET['number']
The processing of multi-adopts is quite tricky, you will need a while or for loop to complete the task. Find this section of code:
PHP Code:
// If we can adopt this creature, do the adoption if($canadopt == "yes") { if (changecash(-$row->cost, $GLOBALS['loggedinname'], $GLOBALS['money'])==true) { // BEGIN the actual adoption process
// First we see if we have a custom name; if not, we use the default name if($name == "") $name = $row->type;
// Now we determine if we are using alternate images or not
$alts = getaltstatus($id, 0, 0);
// We need a unique code for the adoptable so we can show it to the user when we're done here...
$code = codegen(10, 0); $genders = array('f', 'm'); $rand = rand(0,1); $adopts->insert("owned_adoptables", array("aid" => NULL, "type" => $row->type, "name" => $name, "owner" => $loggedinname, "currentlevel" => 0, "totalclicks" => 0, "code" => $code, "imageurl" => NULL, "usealternates" => $alts, "tradestatus" => 'fortrade', "isfrozen" => 'no', "gender" => $genders[$rand], "lastbred" => 0)); // Adoption complete, show the user a confirmation screen...
$owned_adoptable = $adopts->select("owned_adoptables", array(), "code='{$code}' and owner='{$loggedinname}'")->fetchObject(); $id = $owned_adoptable->aid;
$article_title = $name." adopted successfully"; $article_content = "<img src='{$row->eggimage}'><br>{$congrats1} {$name}. You can now manage {$name} on the <a href='myadopts.php'>My Adopts</a> page.<br><br><b><a href='myadopts.php?act=manage&id={$id}'>Click Here to Manage {$name}</a><br> <a href='myadopts.php?act=bbcode&id={$id}'>Click Here to get BBCodes / HTML Codes for {$name}</a></b><br><br> Be sure and <a href='levelup.php?id={$id}'>feed</a> {$name} with clicks so that they grow!"; unset($_SESSION["allow"]); // END the actual adoption process } else { $article_title = "Not enough money."; $article_content = "You don't have enough {$GLOBALS['settings']['cost']} to buy this adoptable. Earn some money and then try again."; } }
Replace with:
PHP Code:
// If we can adopt this creature, do the adoption if($canadopt == "yes") { if (changecash(-$row->cost*$number, $GLOBALS['loggedinname'], $GLOBALS['money'])==true) { // BEGIN the actual adoption process
for(i = 0; i < $number; i++){
// First we see if we have a custom name; if not, we use the default name if($name == "") $name = $row->type;
// Now we determine if we are using alternate images or not
$alts = getaltstatus($id, 0, 0);
// We need a unique code for the adoptable so we can show it to the user when we're done here...
$code = codegen(10, 0); $genders = array('f', 'm'); $rand = rand(0,1); $adopts->insert("owned_adoptables", array("aid" => NULL, "type" => $row->type, "name" => $name, "owner" => $loggedinname, "currentlevel" => 0, "totalclicks" => 0, "code" => $code, "imageurl" => NULL, "usealternates" => $alts, "tradestatus" => 'fortrade', "isfrozen" => 'no', "gender" => $genders[$rand], "lastbred" => 0)); // Adoption complete, show the user a confirmation screen...
$owned_adoptable = $adopts->select("owned_adoptables", array(), "code='{$code}' and owner='{$loggedinname}'")->fetchObject(); $id = $owned_adoptable->aid;
$article_title = $name." adopted successfully"; $article_content = "<img src='{$row->eggimage}'><br>{$congrats1} {$name}. You can now manage {$name} on the <a href='myadopts.php'>My Adopts</a> page.<br><br><b><a href='myadopts.php?act=manage&id={$id}'>Click Here to Manage {$name}</a><br> <a href='myadopts.php?act=bbcode&id={$id}'>Click Here to get BBCodes / HTML Codes for {$name}</a></b><br><br> Be sure and <a href='levelup.php?id={$id}'>feed</a> {$name} with clicks so that they grow!"; unset($_SESSION["allow"]); // END the actual adoption process } } else { $article_title = "Not enough money."; $article_content = "You don't have enough {$GLOBALS['settings']['cost']} to buy this adoptable with the entered quantity. Earn some money and then try again."; } }
Keep in mind that this is a drastic change of the script and I cannot promise that you won't be getting lots of unexpected errors. Lemme know if anything happens though, they should not be hard to fix.
|