IsaacP Posted November 27, 2011 Posted November 27, 2011 I need help with my inventory, when you equip an item it doesn't show equipped but you can attack, and players can't unequip the item. help please Quote
gurpreet Posted November 27, 2011 Posted November 27, 2011 Post up your code so people can see what's wrong with it. Quote
IsaacP Posted November 27, 2011 Author Posted November 27, 2011 (edited) <?php include "globals.php"; print "<h3>Equipped Items</h3><hr />"; while($r=$db->fetch_row($q)) { $equip[$r['itmid']]=$r; } print "<table width='75%' cellspacing='1' class='table'> <tr> <th>Primary Weapon</th> <td>"; if($equip[$ir['equip_primary']]['itmid']) { print $equip[$ir['equip_primary']]['itmname']."</td><td><a href='unequip.php?type=equip_primary'>Unequip Item</a></td>"; } else { print "None equipped.</td><td> </td>"; } print "</tr> <tr> <th>Secondary Weapon</th> <td>"; if($equip[$ir['equip_secondary']]['itmid']) { print $equip[$ir['equip_secondary']]['itmname']."</td><td><a href='unequip.php?type=equip_secondary'>Unequip Item</a></td>"; } else { print "None equipped.</td><td> </td>"; } print "</tr> <tr> <th>Armor</th> <td>"; if($equip[$ir['equip_armor']]['itmid']) { print $equip[$ir['equip_armor']]['itmname']."</td><td><a href='unequip.php?type=equip_armor'>Unequip Item</a></td>"; } else { print "None equipped.</td><td> </td>"; } print "</tr> </table><hr /> <h3>Inventory</h3><hr />"; $inv=$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_userid={$userid} ORDER BY i.itmtype ASC, i.itmname ASC"); if ($db->num_rows($inv) == 0) { print "<b>You have no items!</b>"; } else { print "<b>Your items are listed below.</b><br /> <table width=100% 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']; print "\n<tr><td colspan=4><b>{$lt}</b></td></tr>"; } if($i['weapon']) { $i['itmname']="<font color='red'>*</font>".$i['itmname']; } if($i['armor']) { $i['itmname']="<font color='green'>*</font>".$i['itmname']; } print "<tr><td>{$i['itmname']}"; if ($i['inv_qty'] > 1) { print " x{$i['inv_qty']}"; } print "</td><td>\${$i['itmsellprice']}</td><td>"; print "$".($i['itmsellprice']*$i['inv_qty']); print "</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']) { print " [<a href='itemuse.php?ID={$i['inv_id']}'>Use</a>]"; } if($i['weapon']) { print " [<a href='equip_weapon.php?ID={$i['inv_id']}'>Equip as Weapon</a>]"; } if($i['armor']) { print " [<a href='equip_armor.php?ID={$i['inv_id']}'>Equip as Armor</a>]"; } print "</td></tr>"; } print "</table>"; print "<small><b>NB:</b> Items with a small red </small><font color='red'>*</font><small> next to their name can be used as weapons in combat.<br /> Items with a small green </small><font color='green'>*</font><small> next to their name can be used as armor in combat.</small>"; } $h->endpage(); ?> ok here is my inventory Edited November 27, 2011 by IsaacP Quote
lucky3809 Posted November 28, 2011 Posted November 28, 2011 You have no query at the top so what are you calling in your while statement? while($r=$db->fetch_row($q)) { Quote
IsaacP Posted November 29, 2011 Author Posted November 29, 2011 I have no clue, as I said I don't know whats wrong with it Quote
lucky3809 Posted November 29, 2011 Posted November 29, 2011 Yeah your missing the query that is selecting your equipped weapons ... <?php include "globals.php"; $q=$db->query("SELECT * FROM items WHERE itmid IN({$ir['equip_primary']}, {$ir['equip_secondary']}, {$ir['equip_armor']})"); print "<h3>Equipped Items</h3><hr />"; Quote
IsaacP Posted December 1, 2011 Author Posted December 1, 2011 thanks so much! that fixed it right up. I'm a dunce lol Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.