will this code work? (sort of blacksmith idea)

Forum
Last Post
Threads / Messages

schepers12

Member
Premium Member
Joined
Sep 18, 2012
Messages
26
Points
0
Location
netherlands
Mysidian Dollar
5,176
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:
<?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);

?>
 
Last edited:

Similar threads

Users who are viewing this thread

  • Forum Contains New Posts
  • Forum Contains No New Posts

Forum statistics

Threads
4,277
Messages
33,122
Members
1,602
Latest member
BerrieMilk
BETA

Latest Threads

Latest Posts

Top