DELETE-ME-NOW- Posted July 12, 2010 Share Posted July 12, 2010 When i goto equip a weapon or an armour, it comes up saying. 'This item cannot be equipped to this slot.' I think it has something to do with this part of my inventory.php: } { print " [Equip as Weapon]"; } { print " [Equip as Armor]"; } print "</td></tr>"; is there anything i could change here? Any help would be great! Quote Link to comment Share on other sites More sharing options...
rulerofzu Posted July 12, 2010 Share Posted July 12, 2010 Check the item see if it is actually a weapon or armor. The message is coming from the equip_armor.php and equip_weapon.php files not the inventory. Quote Link to comment Share on other sites More sharing options...
DELETE-ME-NOW- Posted July 12, 2010 Author Share Posted July 12, 2010 The items are right. What would i need to change on equip_***.php? Quote Link to comment Share on other sites More sharing options...
DELETE-ME-NOW- Posted July 12, 2010 Author Share Posted July 12, 2010 Could someone please post there 'inventory.php', 'equip_weapon.php', and there 'equip_armour.php' codes please, as i think there is an error in one of my codes. Quote Link to comment Share on other sites More sharing options...
Danny696 Posted July 12, 2010 Share Posted July 12, 2010 Its nothing to do with them :/ Quote Link to comment Share on other sites More sharing options...
Danny696 Posted July 12, 2010 Share Posted July 12, 2010 Post your inv, from the code above, it doesnt look right :/ Quote Link to comment Share on other sites More sharing options...
DELETE-ME-NOW- Posted July 12, 2010 Author Share Posted July 12, 2010 <?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 />"; 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>[url='unequip.php?type=equip_primary']Unequip Item[/url]</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>[url='unequip.php?type=equip_secondary']Unequip Item[/url]</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>[url='unequip.php?type=equip_armor']Unequip Item[/url]</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] <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>[[url='iteminfo.php?ID={$i[']Info[/url]] [[url='itemsend.php?ID={$i[']Send[/url]] [[url='itemsell.php?ID={$i[']Sell[/url]] [[url='imadd.php?ID={$i[']Add To Market[/url]]"; if($i['effect1_on'] || $i['effect2_on'] || $i['effect3_on']) { print " [[url='itemuse.php?ID={$i[']Use[/url]]"; } if($i['weapon']) { print " [[url='equip_weapon.php?ID={$i[']Equip as Weapon[/url]]"; } if($i['armor']) { print " [[url='equip_armor.php?ID={$i[']Equip as Armor[/url]]"; } print "</td></tr>"; } print "</table>"; print "[size="1"][b]NB:[/b] Items with a small red [/size]<font color='red'>*</font>[size="1"] next to their name can be used as weapons in combat. Items with a small green [/size]<font color='green'>*</font>[size="1"] next to their name can be used as armor in combat.[/size]"; } $h->endpage(); ?> Quote Link to comment Share on other sites More sharing options...
Danny696 Posted July 12, 2010 Share Posted July 12, 2010 Hmm, post your equip_armor.php Quote Link to comment Share on other sites More sharing options...
DELETE-ME-NOW- Posted July 12, 2010 Author Share Posted July 12, 2010 <?php include "globals.php"; $_GET['ID'] = abs((int) $_GET['ID']); $id=$db->query("SELECT iv.*,it.* FROM inventory iv LEFT JOIN items it ON iv.inv_itemid=it.itmid WHERE iv.inv_id={$_GET['ID']} AND iv.inv_userid=$userid LIMIT 1"); if($db->num_rows($id)==0) { print "Invalid item ID"; $h->endpage(); exit; } else { $r=$db->fetch_row($id); } $h->endpage(); exit; } if($_GET['type']) { if(!in_array($_GET['type'], array("equip_armor"))) { print "This slot ID is not valid."; $h->endpage(); exit; } if($ir[$_GET['type']]) { item_add($userid, $ir[$_GET['type']], 1); } item_remove($userid, $r['itmid'], 1); $db->query("UPDATE users SET {$_GET['type']} = {$r['itmid']} WHERE userid={$userid}"); print "Item {$r['itmname']} equipped successfully."; } else { print "<h3>Equip Armor</h3><hr /> <form action='equip_armor.php' method='get'> <input type='hidden' name='ID' value='{$_GET['ID']}' /> Click Equip Armor to equip {$r['itmname']} as your armor, if you currently have any armor equipped it will be removed back to your inventory. <input type='hidden' name='type' value='equip_armor' /> <input type='submit' value='Equip Armor' /></form>"; } $h->endpage(); ?> Quote Link to comment Share on other sites More sharing options...
Danny696 Posted July 12, 2010 Share Posted July 12, 2010 Your trying to equip a peice of armor as a weapon :) Quote Link to comment Share on other sites More sharing options...
DELETE-ME-NOW- Posted July 12, 2010 Author Share Posted July 12, 2010 Your trying to equip a peice of armor as a weapon :) Nope. Ive tried equiping it as a weapon. Same message. Quote Link to comment Share on other sites More sharing options...
Danny696 Posted July 12, 2010 Share Posted July 12, 2010 I know, i ment thats why your gettin the error. you said the error you got was This item cannot be equipped to this slot. Notice its not in the equip_armor.php but its in the equip_weapon.php :) Quote Link to comment Share on other sites More sharing options...
Uridium Posted July 13, 2010 Share Posted July 13, 2010 equip_armor.php <?php include "globals.php"; $_GET['ID'] = abs((int) $_GET['ID']); $id=$db->query("SELECT iv.*,it.* FROM inventory iv LEFT JOIN items it ON iv.inv_itemid=it.itmid WHERE iv.inv_id={$_GET['ID']} AND iv.inv_userid=$userid LIMIT 1"); if($db->num_rows($id)==0) { print "Invalid item ID"; $h->endpage(); exit; } else { $r=$db->fetch_row($id); } if(!$r['armor']) { print "This item cannot be equipped to this slot."; $h->endpage(); exit; } if($_GET['type']) { if(!in_array($_GET['type'], array("equip_armor"))) { print "This slot ID is not valid."; $h->endpage(); exit; } if($ir[$_GET['type']]) { item_add($userid, $ir[$_GET['type']], 1); } item_remove($userid, $r['itmid'], 1); $db->query("UPDATE users SET {$_GET['type']} = {$r['itmid']} WHERE userid={$userid}"); print "Item {$r['itmname']} equipped successfully.<META HTTP-EQUIV=Refresh CONTENT='1;url=inventory.php'>"; } else { print "<h3>Equip Armor</h3><hr /> <form action='equip_armor.php' method='get'> <input type='hidden' name='ID' value='{$_GET['ID']}' /> Click Equip Armor to equip {$r['itmname']} as your armor, if you currently have any armor equipped it will be removed back to your inventory. <input type='hidden' name='type' value='equip_armor' /> <input type='submit' value='Equip Armor' /></form>"; } $h->endpage(); ?> And incase your having problems with weapons its exactly the same code as above just change the word armor to weapon and save as equip_weapon.php Quote Link to comment Share on other sites More sharing options...
DELETE-ME-NOW- Posted July 13, 2010 Author Share Posted July 13, 2010 Used that code, and still 'This item cannot be equipped to this slot.' Quote Link to comment Share on other sites More sharing options...
Dominion Posted July 13, 2010 Share Posted July 13, 2010 post your inventory and both equip files Quote Link to comment Share on other sites More sharing options...
DELETE-ME-NOW- Posted July 13, 2010 Author Share Posted July 13, 2010 inventory.php <?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 />"; 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>[url='unequip.php?type=equip_primary']Unequip Item[/url]</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>[url='unequip.php?type=equip_secondary']Unequip Item[/url]</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>[url='unequip.php?type=equip_armor']Unequip Item[/url]</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] <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>[[url='iteminfo.php?ID={$i[']Info[/url]] [[url='itemsend.php?ID={$i[']Send[/url]] [[url='itemsell.php?ID={$i[']Sell[/url]] [[url='imadd.php?ID={$i[']Add To Market[/url]]"; if($i['effect1_on'] || $i['effect2_on'] || $i['effect3_on']) { print " [[url='itemuse.php?ID={$i[']Use[/url]]"; } if($i['weapon']) { print " [[url='equip_weapon.php?ID={$i[']Equip as Weapon[/url]]"; } if($i['armour']) { print " [[url='equip_armor.php?ID={$i[']Equip as Armor[/url]]"; } print "</td></tr>"; } print "</table>"; print "[size="1"][b]NB:[/b] Items with a small red [/size]<font color='red'>*</font>[size="1"] next to their name can be used as weapons in combat. Items with a small green [/size]<font color='green'>*</font>[size="1"] next to their name can be used as armor in combat.[/size]"; } $h->endpage(); ?> equip_armour.php <?php include "globals.php"; $_GET['ID'] = abs((int) $_GET['ID']); $id=$db->query("SELECT iv.*,it.* FROM inventory iv LEFT JOIN items it ON iv.inv_itemid=it.itmid WHERE iv.inv_id={$_GET['ID']} AND iv.inv_userid=$userid LIMIT 1"); if($db->num_rows($id)==0) { print "Invalid item ID"; $h->endpage(); exit; } else { $r=$db->fetch_row($id); } if(!$r['armor']) { print "This item cannot be equipped to this slot."; $h->endpage(); exit; } if($_GET['type']) { if(!in_array($_GET['type'], array("equip_armor"))) { print "This slot ID is not valid."; $h->endpage(); exit; } if($ir[$_GET['type']]) { item_add($userid, $ir[$_GET['type']], 1); } item_remove($userid, $r['itmid'], 1); $db->query("UPDATE users SET {$_GET['type']} = {$r['itmid']} WHERE userid={$userid}"); print "Item {$r['itmname']} equipped successfully.<META HTTP-EQUIV=Refresh CONTENT='1;url=inventory.php'>"; } else { print "<h3>Equip Armor</h3><hr /> <form action='equip_armor.php' method='get'> <input type='hidden' name='ID' value='{$_GET['ID']}' /> Click Equip Armor to equip {$r['itmname']} as your armor, if you currently have any armor equipped it will be removed back to your inventory. <input type='hidden' name='type' value='equip_armor' /> <input type='submit' value='Equip Armor' /></form>"; } $h->endpage(); ?> equip_weapon.php <?php include "globals.php"; $_GET['ID'] = abs((int) $_GET['ID']); $id=$db->query("SELECT iv.*,it.* FROM inventory iv LEFT JOIN items it ON iv.inv_itemid=it.itmid WHERE iv.inv_id={$_GET['ID']} AND iv.inv_userid=$userid LIMIT 1"); if($db->num_rows($id)==0) { print "Invalid item ID"; $h->endpage(); exit; } else { $r=$db->fetch_row($id); } if(!$r['weapon']) { print "This item cannot be equipped to this slot."; $h->endpage(); exit; } if($_GET['type']) { if(!in_array($_GET['type'], array("equip_primary", "equip_secondary"))) { print "This slot ID is not valid."; $h->endpage(); exit; } if($ir[$_GET['type']]) { item_add($userid, $ir[$_GET['type']], 1); } item_remove($userid, $r['itmid'], 1); $db->query("UPDATE users SET {$_GET['type']} = {$r['itmid']} WHERE userid={$userid}"); print "Item {$r['itmname']} equipped successfully."; } else { print "<h3>Equip Weapon</h3><hr /> <form action='equip_weapon.php' method='get'> <input type='hidden' name='ID' value='{$_GET['ID']}' /> Please choose the slot to equip {$r['itmname']} to, if there is already a weapon in that slot, it will be removed back to your inventory. <input type='radio' name='type' value='equip_primary' checked='checked' /> Primary <input type='radio' name='type' value='equip_secondary' /> Secondary <input type='submit' value='Equip Weapon' /></form>"; } $h->endpage(); ?> Quote Link to comment Share on other sites More sharing options...
Danny696 Posted July 13, 2010 Share Posted July 13, 2010 Ok, try this file and tell me the results: <?php include "globals.php"; $_GET['ID'] = abs((int) $_GET['ID']); $id=$db->query("SELECT iv.*,it.* FROM inventory iv LEFT JOIN items it ON iv.inv_itemid=it.itmid WHERE iv.inv_id={$_GET['ID']} AND iv.inv_userid=$userid LIMIT 1"); if($db->num_rows($id)==0) { print "Invalid item ID"; $h->endpage(); exit; } else { $r=$db->fetch_row($id); } echo $r['armor']; $h->endpage(); ?> Quote Link to comment Share on other sites More sharing options...
DELETE-ME-NOW- Posted July 13, 2010 Author Share Posted July 13, 2010 Ok, try this file and tell me the results: <?php include "globals.php"; $_GET['ID'] = abs((int) $_GET['ID']); $id=$db->query("SELECT iv.*,it.* FROM inventory iv LEFT JOIN items it ON iv.inv_itemid=it.itmid WHERE iv.inv_id={$_GET['ID']} AND iv.inv_userid=$userid LIMIT 1"); if($db->num_rows($id)==0) { print "Invalid item ID"; $h->endpage(); exit; } else { $r=$db->fetch_row($id); } echo $r['armor']; $h->endpage(); ?> Try that on what file? Quote Link to comment Share on other sites More sharing options...
rulerofzu Posted July 13, 2010 Share Posted July 13, 2010 Cant see anything wrong. Go back to the database and check the items and your users table for the equip slots. Quote Link to comment Share on other sites More sharing options...
DELETE-ME-NOW- Posted July 13, 2010 Author Share Posted July 13, 2010 when i create an item, when it asked for item type, i had to create an item type called 'weapon'. Made an item with weapon type, still the same error Quote Link to comment Share on other sites More sharing options...
DELETE-ME-NOW- Posted July 13, 2010 Author Share Posted July 13, 2010 NB: Items with a small red * next to their name can be used as weapons in combat. Items with a small green * next to their name can be used as armor in combat. The items aint got teh star. And only equip shows when i delete the if($i['weapon'....... Quote Link to comment Share on other sites More sharing options...
iSOS Posted July 13, 2010 Share Posted July 13, 2010 I thought someone would have mentioned this. I bet you haven't set the "weapon" value to anything other than 0. :huh: Quote Link to comment Share on other sites More sharing options...
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.