Mysidia Adoptables Support Forum  

Home Community Mys-Script Creative Off-Topic
Go Back   Mysidia Adoptables Support Forum > Mysidia Adoptables > Questions and Supports

Notices

Reply
 
Thread Tools Display Modes
  #1  
Old 04-14-2012, 10:04 AM
SilverDragonTears's Avatar
SilverDragonTears SilverDragonTears is offline
I am your Nemesis.
 
Join Date: Jun 2011
Posts: 1,113
Gender: Female
Credits: 82,590
SilverDragonTears is on a distinguished road
Default Sell Items not working

When you sell an item it doesn't give you any money back. No error, just no cash.
__________________

Check out SilvaTales
Reply With Quote
  #2  
Old 04-14-2012, 10:32 AM
Hall of Famer's Avatar
Hall of Famer Hall of Famer is offline
Administrator, Lead Coder
 
Join Date: Dec 2008
Location: South Brunswick
Posts: 4,448
Gender: Male
Credits: 338,406
Hall of Famer is on a distinguished road
Default

umm it works fine on my site, did it work for you before the changes in class_item.php files are made?
__________________


Mysidia Adoptables, a free and ever-improving script for aspiring adoptables/pets site.
Reply With Quote
  #3  
Old 04-14-2012, 10:38 AM
SilverDragonTears's Avatar
SilverDragonTears SilverDragonTears is offline
I am your Nemesis.
 
Join Date: Jun 2011
Posts: 1,113
Gender: Female
Credits: 82,590
SilverDragonTears is on a distinguished road
Default

I'm not sure... just now trying it out.

class_item.php

Code:
<?php

class Item{
  public $id;
  public $category;
  public $itemname;
  public $description;
  public $imageurl;
  public $function;
  public $target;
  public $shop;
  public $price;
  public $chance;
  public $cap;
  public $tradable;
  public $consumable;

  public function __construct($itemname){
	  // Fetch the database info into object property
	  $row = $GLOBALS['adopts']->select("items", array(), "itemname ='{$itemname}'")->fetchObject();
	  // loop through the anonymous object created to assign properties
      foreach($row as $key => $val){
         $this->$key = $val;		 
      }	    
  }

  public function getcategory(){
      // This method checks if the item category exists in items database or not
	  
	  $stmt = $GLOBALS['adopts']->select("items", array(), "category ='{$this->category}'");
      $cate_exist = ($row = $stmt->fetchObject())?TRUE:FALSE;     
	  return $cate_exist;
  }
 
  public function getitem(){
      // This method checks if the item exists in items database or not
	  
	  $stmt = $GLOBALS['adopts']->select("items", array(), "itemname ='{$this->itemname}'");
      $item_exist = ($row = $stmt->fetchObject())?TRUE:FALSE;     
	  return $item_exist;
  }
 
  public static function getitemimage($imageurl){
      // This method returns the item image in standard html form
   
      $imageurl = (strpos($imageurl, "http://") !== false)?$imageurl:"http://{$imageurl}";
      $image = "<img src='{$imageurl}'>";
      return $image;	  
  }

public function checktarget($aid){
      // This method checks if the item is usable
      $id = converttypetoparentid(convertidtotype($aid));
      $item_usable = FALSE;
      switch($this->target){
         case "all":
            $item_usable = TRUE;
            break;
         case "user":
            $item_usable = TRUE;
            break;
         default:
            $target = explode(",",$this->target);
            if(in_array($id, $target)) $item_usable = TRUE;            
      }
      return $item_usable;
  }
  
  public function randomchance(){
      // This method returns the item image in standard html form
	  switch($this->chance){
	     case 100:
            $item_usable = TRUE;
		    break;
         default:
		    $temp = mt_rand(0,99);
			$item_usable = ($temp < $this->chance)?TRUE:FALSE;
	  }
      return $item_usable;	  
  }
}

class Private_Item extends Item{
  public $iid;
  public $owner;
  public $quantity;
  public $status;
  
  public function __construct($itemname, $itemowner, $itemquantity = ""){
      // First of all, let's assign values to parent properties
      parent::__construct($itemname);
	 
	  // Good, now it is time to assign child properties. First let's use $itemquantity to check if it is a new item or an item in inventory
      if(empty($itemquantity)){
	    // the item is an owned item in user inventory, so retrieve database info to assign properties
	     $row = $GLOBALS['adopts']->select("inventory", array(), "itemname ='{$itemname}' and owner = '{$itemowner}'")->fetchObject();
         // loop through the anonymous object created to assign properties
         foreach($row as $key => $val){
            $this->$key = $val;
         }	 
	  }
      else{
         // the item is a new item to be added or used, and does not belong to anyone at this very moment.
         $this->owner = (!empty($itemowner))?$itemowner:"SYSTEM";
         $this->quantity = $itemquantity;
         $this->status = "Available";           
      }	  
      // the private item object is successfully created with appropriate properties assigned.	
  }
 
  public function getitem(){
      // This method checks if the item exists in inventory or not, not to be confused with parent class' getitem() class.
	  
	  $stmt = $GLOBALS['adopts']->select("inventory", array(), "itemname ='{$this->itemname}' and owner ='{$this->owner}'"); 
	  return $stmt->fetchObject();
  }
 
  public function getitemcost($salestax = 0){
      // This method returns the cost of items.
	  
      $cost = $this->price*$this->quantity*(1 + $salestax/100);
	  return $cost;
  }
  
  public static function getoldquantity($itemname, $owner = ""){
      // This method returns the quantity of items the owner already has, do not call unless both old and new quantities need to be used in script
	  $owner = (!empty($owner))?$owner:$GLOBALS['loggedinname'];
	  $stmt = $GLOBALS['adopts']->select("inventory", array("quantity"), "itemname ='{$itemname}' and owner ='{$owner}'"); 
      $oldquantity = $stmt->fetchColumn();
      return $oldquantity;	  
  }

  public static function showinventory($owner){
      // This method returns a list of items the user owned

	  $stmt = $GLOBALS['adopts']->join("items", "items.itemname = inventory.itemname")
							    ->select("inventory", array(), constant("PREFIX")."inventory.owner = '{$owner}' ORDER BY ".constant("PREFIX")."inventory.iid");  
      $table = new Table("Inventory", array("Image", "Category", "Name", "Description", "Quantity", "Use", "Sell", "Toss"));
      $content = $table->getheader();	
				  
	  while($row = $stmt->fetchObject()){
	     // First we need to retrieve item properties.      						  
      	 $use = ($row->consumable == "yes")?"<form name='use' method='post' action='inventory.php?act=useitem'>
                    <p><input name='act' type='hidden' id='act' value='{$row->itemname}'>
	    	        <input name='itemname' type='hidden' id='itemname' value='{$row->itemname}'></p>
					<p><input type='submit' name='use' value='Use'></p></form>":"N/A";

         $sell = ($row->category == "Key Items")?"N/A":"<form name='sell' method='post' action='inventory.php?act=sellitem'>
                     <input name='itemname' type='hidden' id='itemname' value='{$row->itemname}'>
                     <input name='quantity' type='text' id='quantity' size='3' maxlength='3' />
                     <p><input type='submit' name='Submit' value='Sell'></p></form>";
			
	     $toss = ($row->category == "Key Items")?"N/A":"<form name='toss' method='post' action='inventory.php?act=tossitem'>
                     <p><input name='act' type='hidden' id='act' value='{$row->itemname}'>
		             <input name='itemname' type='hidden' id='itemname' value='{$row->itemname}'></p>
                     <p><input type='submit' name='toss' value='Toss'></p></form>";
          
         $content .= $table->buildtable(array(Item::getitemimage($row->imageurl), $row->category, $row->itemname, $row->description, $row->quantity, $use, $sell, $toss), "center")->showtable();
	  }
	  $content .= $table->endtable();
      return $content;	  
  }
  
  public function additem($quantity= 1, $owner = ""){
      // This method adds items to users inventory
  
      $this->owner = (!empty($owner))?$owner:$this->owner;
	  $oldquantity = Private_Item::getoldquantity($this->itemname, $owner);	  
      if($oldquantity > 0){
	     // the item already exists, update the row for user's inventory
	     $newquantity = $oldquantity + $quantity;
		 $GLOBALS['adopts']->update("inventory", array("quantity" => $newquantity), "itemname ='{$this->itemname}' and owner='{$this->owner}'");  
	  }
	  else{	     
		 // the item does not exist yet, insert a new row into user's inventory
		 $GLOBALS['adopts']->insert("inventory", array("iid" => NULL, "category" => $this->category, "itemname" => $this->itemname, "owner" => $this->owner, "quantity" => $quantity, "status" => 'Available'));
	  }
	  
	  $state = "success";
	  return $state;
  }
  
  public function removeitem($quantity = 1, $owner = ""){
      // This method removes items from users inventory
  
      $this->owner = (!empty($owner))?$owner:$this->owner;
      $oldquantity = Private_Item::getoldquantity($this->itemname, $owner);	  
      $newquantity = $oldquantity - $quantity;
	  if(empty($oldquantity) or $newquantity < 0) return FALSE;
	  else{
	     switch($newquantity){
		    case 0:
			   $GLOBALS['adopts']->delete("inventory", "itemname='{$this->itemname}' and owner='{$this->owner}'");
			   break;
			default:
			   $GLOBALS['adopts']->update("inventory", array("quantity" => $newquantity), "itemname ='{$this->itemname}' and owner='{$this->owner}'");
		 }
	     return TRUE;
	  }
  }

  public function sellitem($quantity = 1, $owner = ""){
      // This method sells items from users inventory
      $this->owner = (!empty($owner))?$owner:$this->owner;
      $earn = $this->price*$quantity;      
      $newamount = $GLOBALS['money'] + $earn;
      if($this->removeitem($quantity, $this->owner)){
         $GLOBALS['adopts']->update("users", array("money" => $newamount), "username = '{$this->owner}'");
	     return TRUE;
      }
      else return FALSE; 	 
  }

  public function choosetarget(){
      // This method chooses the adoptable or user to use the item on
      $content = "Now you need to choose an adoptable to use item {$this->itemname}:
      <form name='use' method='post' action='inventory.php?act=useitem&more=process'>
      <input name='act' type='hidden' id='act' value='useitem'>
      <p><select name='aid'>";

      $stmt = $GLOBALS['adopts']->select("owned_adoptables", array(), "owner ='{$this->owner}'"); 
      while($row = $stmt->fetchObject()){
         $content .= "<option value='{$row->aid}'>{$row->name} (the {$row->type})</option>";
      }

      $content .= "</select><input name='itemname' type='hidden' id='itemname' value='{$this->itemname}'>
      <p><input name='validation' type='hidden' id='validation' value='valid'>
      <input type='submit' name='submit' value='Use'></p>
      </form>";
      return $content;
  }
}
?>
__________________

Check out SilvaTales
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Mys 1.3.4 - Items for certain currentlevel draugluin Questions and Supports 2 04-23-2015 03:26 AM
Items not working kristhasirah Questions and Supports 1 09-09-2013 10:05 PM
Target for Items not working SilverDragonTears Questions and Supports 3 04-12-2012 04:17 AM
Certain Items Won't Be Added? AlexC Questions and Supports 4 03-27-2012 03:22 PM
Sell pups 4 forum credits RoconzaArt Art Gallery 3 02-24-2011 08:17 AM


All times are GMT -5. The time now is 06:56 AM.

Currently Active Users: 9677 (0 members and 9677 guests)
Threads: 4,080, Posts: 32,024, Members: 2,016
Welcome to our newest members, jolob.
BETA





What's New?

What's Hot?

What's Popular?


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
vBCommerce I v2.0.0 Gold ©2010, PixelFX Studios
vBCredits I v2.0.0 Gold ©2010, PixelFX Studios
Emoticons by darkmoon3636