schepers12 |
09-22-2012 04:17 PM |
will this code work? (sort of blacksmith idea)
hello all, i have a question, will this code work how it supposed to work?
(for example: take 10 gold powder away and add in most cases 2 gold coins, otherwise it's a failure..)
i'm just asking to be sure, as i don't really know how the MYS engine exactly works... ^^;;
the full php & html code:
GOT IT TO WORK, the working code is:
PHP Code:
<?php
include("functions/functions.php"); include("functions/functions_users.php"); include("functions/functions_adopts.php"); include("functions/functions_items.php"); include("classes/class_item.php"); include("inc/lang.php");
//***************// // START SCRIPT // //***************// $name1 = "gold powder"; // the item you want to give to the blacksmith $amount1 = "10"; // the amount of the item you need to give to the blacksmith $name2 = "gold coins"; // the name of the item you want to add by the blacksmith $amount2 = "2"; //the amount of items you want to receive from the blacksmith $userstatus = getuserstatus($loggedinname);
if($isloggedin == "yes" and $userstatus['canshop'] == "yes"){ if($_GET["act"] == "do"){ $item = new Private_Item($name1, $loggedinname, $quantity); if ($item >= $amount1){ $chance = rand(1,10); if ($change < 8){ $item = new Private_Item($name1, $loggedinname, $quantity); $item2 = new Private_Item($name2, $loggedinname, $quantity); if($item->removeitem($amount1, $loggedinname)){ $newquantity = $oldquantity - $amount1; $item2->additem($amount2,$loggedinname); $article_title = "Success!"; $article_content = "Success! {$amount1} of your {$name1} has been molten into {$amount2} pieces of {$name2} !"; } else { $article_title = "You don't have enough {$name1}!"; } } else { $oldquantity = Private_Item::getoldquantity($name1, $loggedinname); $newquantity = $oldquantity - $amount1; $article_title = "failure!"; $article_content = "the melting has gone wrong sadly, all of the {$name1} has gone to waste.."; } } else { $article_title = "You don't have enough {$name1}!"; } } else{ $article_title = "Confirm your action"; $article_content = "Melt your {$name1} to {$name2}. you need {$amount1} of {$name1} to get {$amount2} pieces of {$name2}.<br>There is a change of failure though! <form name='do' method='post' action='blacksmith.php?act=do'> <input name='itemname' type='hidden' id='itemname' value='{$item}'><p><input type='submit' name='do' value='Make {$name2}'></p></form>"; } }else{ $article_title = $accden; $article_content = $reqlogin; } // End is logged in check else //***************// // OUTPUT PAGE // //***************//
echo showpage($article_title, $article_content, $date);
?>
|