Jump to content
MakeWebGames

My Inventory


Scorpio
 Share

Recommended Posts

Hey there my inventory the item gets duplicated.

I believe it is my item use which is doing this!

I have got and randomizer and cronuses dp mod installed

Here my item use can someone help me out please?

 

<?php
/**
* MCCodes Version 2.0.5b
* Copyright (C) 2005-2012 Dabomstew
* All rights reserved.
*
* Redistribution of this code in any form is prohibited, except in
* the specific cases set out in the MCCodes Customer License.
*
* This code license may be used to run one (1) game.
* A game is defined as the set of users and other game database data,
* so you are permitted to create alternative clients for your game.
*
* If you did not obtain this code from MCCodes.com, you are in all likelihood
* using it illegally. Please contact MCCodes to discuss licensing options
* in this case.
*
* File: itemuse.php
* Signature: 9633f89704acd2ba6a05feab908b636d
* Date: Fri, 20 Apr 12 08:50:30 +0000
*/

require_once('globals.php');
$i=$db->query("SELECT iv.*,i.*,it.* FROM inventory iv LEFT JOIN items i ON iv.inv_itemid=i.itmid LEFT JOIN itemtypes it ON i.itmtype=it.itmtypeid WHERE iv.inv_id={$_GET['ID']} AND iv.inv_userid=$userid");
if(mysql_num_rows($i) == 0)
{
print "Invalid item ID";
}
else
{
$r=$db->fetch_row($i);
if($r['itmtypeid'] == 5)
{
$look=$db->query("SELECT * FROM dpacks WHERE id={$r['itmid']}");
$dp=$db->fetch_row($look);
print"<br><br><center>You opened your {$r['itmname']} and look inside.<br>";
if($dp['days'] > 0)
{
$days=$dp['days'];
$db->query("UPDATE users SET donatordays=donatordays+$days WHERE userid=$userid");
print"You find $days Donator Days!<br>";
}
if($dp['crystals'] > 0)
{
$crystals=$dp['crystals'];
$db->query("UPDATE users SET crystals=crystals+$crystals WHERE userid=$userid");
print"You find $crystals Crystals!<br>";
}
if($dp['money'] > 0)
{
$money=$dp['money'];
$muneh=money_formatter($money);
$db->query("UPDATE users SET money=money+$money WHERE userid=$userid");
print"You find $muneh!<br>";
}
if($dp['items'] > 0)
{
$mok=$db->query("SELECT * FROM dpitems WHERE dpid={$dp['id']}");
while($item=$db->fetch_row($mok))
{
$i=$db->query("INSERT INTO inventory (inv_itemid,inv_userid,inv_qty) values('{$item['itemid']}','$userid','{$item['quantity']}')",$c) or die(mysql_error());
$b=$db->query("SELECT * FROM items WHERE itmid={$item['itemid']}");
$i=$db->query("SELECT iv.*,i.*,it.* FROM inventory iv LEFT JOIN items i ON iv.inv_itemid=i.itmid LEFT JOIN itemtypes it ON i.itmtype=it.itmtypeid WHERE iv.inv_id={$_GET['ID']} AND iv.inv_userid=$userid");
if(mysql_num_rows($i) == 0)




print "Invalid item ID";
$something=$db->fetch_row($b);
print"You found {$item['quantity']} {$something['itmname']}(s)!<br>";
}
}
item_remove($userid, $r['inv_itemid'], 1);
die("");
}
}
$_GET['ID'] =
       (isset($_GET['ID']) && is_numeric($_GET['ID']))
               ? abs(intval($_GET['ID'])) : '';
if (!$_GET['ID'])
{
   echo 'Invalid use of file';
}
else
{
   $i =
           $db->query(
                   "SELECT `effect1`, `effect2`, `effect3`,
                    `effect1_on`, `effect2_on`, `effect3_on`,
                    `itmname`, `inv_itemid`
                    FROM `inventory` AS `iv`
                    INNER JOIN `items` AS `i`
                    ON `iv`.`inv_itemid` = `i`.`itmid`
                    WHERE `iv`.`inv_id` = {$_GET['ID']}
                    AND `iv`.`inv_userid` = $userid");
   if ($db->num_rows($i) == 0)
   {

   }
   else
   {
       $r = $db->fetch_row($i);
       $db->free_result($i);



if($r['itmname'] == 'Randomizer')
{
$chance = rand(1,1);
if ($chance == 1)  {
$gained=rand(10000,250000);
print "

Randomizer Event Unlocked!<br />

You have just revealed the contents of the randomizer rare event.

<br /> <br /><font color=red><b>You gained \$$gained</b>.<br /></font>

";
$db->query("UPDATE users SET money=money+$gained WHERE userid=$userid");
}

if ($chance == 1)  {
$gained=rand(100,300);
print "<font color=red><b>You gained $gained Crystals</b>.<br /></font>

";
$db->query("UPDATE users SET crystals=crystals+$gained WHERE userid=$userid");
}
if ($chance == 1)  {
$gained=rand(1,3);
print "<font color=red><b>You gained $gained Credits</b>.<br /></font>

";
$db->query("UPDATE users SET credits=credits+$gained WHERE userid=$userid");
}
if ($chance == 1)  {
$gained=rand(1,2);
print "<font color=red><b>You gained $gained Will Potion</b>.<br /></font>

";
$db->query("INSERT INTO inventory   VALUES('',1,$userid,$gained)");
}
if ($chance == 1)  {
$gained=rand(3,10);
print "<font color=red><b>You gained $gained Donator Days</b>.<br /></font>

";
$db->query("UPDATE users SET donatordays=donatordays+$gained WHERE userid=$userid");
}
if ($chance == 1)  {
$gained=rand(100,120);
print "<font color=red><b>You gained $gained Steps</b>.<br /></font>

";
$db->query("UPDATE users SET steps=steps+$gained WHERE userid=$userid");
}

if ($chance == 1)  {
$gained=rand(1,2);
print "<font color=red><b>You gained $gained Levels</b>.<br /></font>

";
$db->query("UPDATE users SET level=level+$gained WHERE userid=$userid");
}
if ($chance == 1)  {
$gained=rand(1,2);
print "<font color=red><b>You gained $gained Energy Potion</b>.<br /><br /></font>

";
$db->query("INSERT INTO inventory   VALUES('',2,$userid,$gained)");




}
}
else
{
if(!$r['effect1_on'] && !$r['effect2_on'] && !$r['effect3_on'])
{
 die("Sorry, this item cannot be used as it has no effect.");
}
}

       for ($enum = 1; $enum <= 3; $enum++)
       {
           if ($r["effect{$enum}_on"])
           {
               $einfo = unserialize($r["effect{$enum}"]);
               if ($einfo['inc_type'] == "percent")
               {
                   if (in_array($einfo['stat'],
                           array('energy', 'will', 'brave', 'hp')))
                   {
                       $inc =
                               round(
                                       $ir['max' . $einfo['stat']] / 100
                                               * $einfo['inc_amount']);
                   }
                   else
                   {
                       $inc =
                               round(
                                       $ir[$einfo['stat']] / 100
                                               * $einfo['inc_amount']);
                   }
               }
               else
               {
                   $inc = $einfo['inc_amount'];
               }
               if ($einfo['dir'] == "pos")
               {
                   if (in_array($einfo['stat'],
                           array('energy', 'will', 'brave', 'hp')))
                   {
                       $ir[$einfo['stat']] =
                               min($ir[$einfo['stat']] + $inc,
                                       $ir['max' . $einfo['stat']]);
                   }
                   else
                   {
                       $ir[$einfo['stat']] += $inc;
                   }
               }
               else
               {
                   $ir[$einfo['stat']] = max($ir[$einfo['stat']] - $inc, 0);
               }
               $upd = $ir[$einfo['stat']];
               if (in_array($einfo['stat'],
                       array('strength', 'agility', 'guard', 'labour', 'IQ')))
               {
                   $db->query(
                           "UPDATE `userstats`
                            SET `{$einfo['stat']}` = '{$upd}'
                            WHERE `userid` = {$userid}");
               }
               else
               {
                   $db->query(
                           "UPDATE `users`
                            SET `{$einfo['stat']}` = '{$upd}'
                            WHERE `userid` = {$userid}");
               }
           }
       }
       echo $r['itmname'] . ' used successfully!';
       item_remove($userid, $r['inv_itemid'], 1);
   }
}
$h->endpage();

 

And just incase my inventory!

 

<?php
/**
* MCCodes Version 2.0.5b
* Copyright (C) 2005-2012 Dabomstew
* All rights reserved.
*
* Redistribution of this code in any form is prohibited, except in
* the specific cases set out in the MCCodes Customer License.
*
* This code license may be used to run one (1) game.
* A game is defined as the set of users and other game database data,
* so you are permitted to create alternative clients for your game.
*
* If you did not obtain this code from MCCodes.com, you are in all likelihood
* using it illegally. Please contact MCCodes to discuss licensing options
* in this case.
*
* File: inventory.php
* Signature: 923658342519b486f3b2ebde8fa3d86f
* Date: Fri, 20 Apr 12 08:50:30 +0000
*/

require_once('globals.php');

$q =
       $db->query(
               "SELECT `itmid`, `itmname`
                FROM `items`
                WHERE `itmid`
                 IN({$ir['equip_primary']}, {$ir['equip_secondary']},
                    {$ir['equip_armor']})");
echo "<h3>Equipped Items</h3><hr width=99%/>";
$equip = array();
while ($r = $db->fetch_row($q))
{
   $equip[$r['itmid']] = $r;
}
$db->free_result($q);
echo "<table width='99%' cellspacing='1' class='table'>
<tr>
<th width=25%>Primary Weapon</th>
<td>";
if (isset($equip[$ir['equip_primary']]))
{
   print
           $equip[$ir['equip_primary']]['itmname']
                   . "</td><td><a href='unequip.php?type=equip_primary'>Unequip Item</a></td>";
}
else
{
   echo "None equipped.</td><td> </td>";
}
echo "</tr>
<tr>
<th>Secondary Weapon</th>
<td>";
if (isset($equip[$ir['equip_secondary']]))
{
   print
           $equip[$ir['equip_secondary']]['itmname']
                   . "</td><td><a href='unequip.php?type=equip_secondary'>Unequip Item</a></td>";
}
else
{
   echo "None equipped.</td><td> </td>";
}
echo "</tr>
<tr>
<th>Armor</th>
<td>";
if (isset($equip[$ir['equip_armor']]))
{
   print
           $equip[$ir['equip_armor']]['itmname']
                   . "</td><td><a href='unequip.php?type=equip_armor'>Unequip Item</a></td>";
}
else
{
   echo "None equipped.</td><td> </td>";
}
echo "</tr>
</table><hr width=99%/>
<h3>Inventory</h3><hr width=99%/>";
$inv =
       $db->query(
               "SELECT `inv_qty`, `itmsellprice`, `itmid`, `inv_id`,
                `effect1_on`, `effect2_on`, `effect3_on`, `itmname`,
                `weapon`, `armor`, `itmtypename`
                FROM `inventory` AS `iv`
                INNER JOIN `items` AS `i`
                ON `iv`.`inv_itemid` = `i`.`itmid`
                INNER JOIN `itemtypes` AS `it`
                ON `i`.`itmtype` = `it`.`itmtypeid`
                WHERE `iv`.`inv_userid` = {$userid}
                ORDER BY `i`.`itmtype` ASC, `i`.`itmname` ASC");
if ($db->num_rows($inv) == 0)
{
   echo "<b>You have no items!</b>";
}
else
{
   echo "
<table width=99% class=\"table\" border=\"0\" cellspacing=\"1\">
<tr>
	<td class=\"h\">Item</td>
	<td class=\"h\">Sell Value</td>
	<td class=\"h\">Total Sell Value</td>
	<td class=\"h\">Links</td>
</tr>";
   $lt = "";
   while ($i = $db->fetch_row($inv))
   {
       if ($lt != $i['itmtypename'])
       {
           $lt = $i['itmtypename'];
           echo "\n<tr>
           			<td colspan='4'>
           				<b>{$lt}</b>
           			</td>
           		</tr>";
       }
       if ($i['weapon'])
       {
           $i['itmname'] =
                   "<span style='color: red;'>*</span>" . $i['itmname'];
       }
       if ($i['armor'])
       {
           $i['itmname'] =
                   "<span style='color: green;'>*</span>" . $i['itmname'];
       }
       echo "<tr>
       		<td>{$i['itmname']}";
       if ($i['inv_qty'] > 1)
       {
           echo " x{$i['inv_qty']}";
       }
       echo "</td>
       	  <td>" . money_formatter($i['itmsellprice'])
               . "</td>
       	  <td>";
       echo money_formatter($i['itmsellprice'] * $i['inv_qty']);
       echo "</td>
       	  <td>
       	  	[<a href='iteminfo.php?ID={$i['itmid']}'>Info</a>]
       	  	[<a href='itemsend.php?ID={$i['inv_id']}'>Send</a>]
       	  	[<a href='itemsell.php?ID={$i['inv_id']}'>Sell</a>]
       	  	[<a href='imadd.php?ID={$i['inv_id']}'>Add To Market</a>]";
       if ($i['effect1_on'] || $i['effect2_on'] || $i['effect3_on'])
       {
           echo " [<a href='itemuse.php?ID={$i['inv_id']}'>Use</a>]";
       }
       if($i['itmtypename'] == 'Randomizer')
       {
       echo " [<a href='itemuse.php?ID={$i['inv_id']}'>Use</a>]";
       }
       if ($i['weapon'] > 0)
       {
           echo " [<a href='equip_weapon.php?ID={$i['inv_id']}'>Equip as Weapon</a>]";
       }
       if ($i['armor'] > 0)
       {
           echo " [<a href='equip_armor.php?ID={$i['inv_id']}'>Equip as Armor</a>]";
       }
       echo "</td>
       </tr>";
   }
   echo "</table>";
   $db->free_result($inv);
   echo "<hr width=99%/><small><b>NB:</b> Items with a small red </small><span style='color: red;'>*</span><small> next to their name can be used as weapons in combat.<br />
Items with a small green </small><span style='color: green;'>*</span><small> next to their name can be used as armor in combat.</small><hr width=99%/>";
}




$h->endpage();

 

 

 

Pleasee I really need help with this! If someone helps I will really appericate it!

Edited by Scorpio
Link to comment
Share on other sites

Well what you can do is take a look at your inventory and cross reference it with your inventory rows in the db and see if its actually being duplicated. To me it doesnt look like it would duplicate its just showing you all of your rows instead of actually showing one quantity for each item. I would have to take a look at my inventory to see how its actually done but as long as its not giving people more than they should have its not a show stopper for the time being

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...