SteveDave Posted April 29, 2009 Posted April 29, 2009 I made a mod on my game and I used this code to insert items into an inventory: mysql_query("INSERT INTO inventory VALUES ('', $item, $userid, 1)",$c); But doing that doesn't automatically quantify items together, what should I add to make it do so? Thanks :-D Quote
ShizzleNizzle Posted April 29, 2009 Posted April 29, 2009 Re: Auto quantify Im pretty sure the "item_add" function can be used here. If you look in your global_funcs.php it's in there. I believe thats what it should be for your query. NOTE: untested. item_add($userid,$item,1) Quote
Lithium Posted April 29, 2009 Posted April 29, 2009 Re: Auto quantify Im pretty sure the "item_add" function can be used here. If you look in your global_funcs.php it's in there. I believe thats what it should be for your query. NOTE: untested. item_add($userid,$item,1) This only applies if V2 Quote
wolfe Posted April 29, 2009 Posted April 29, 2009 Re: Auto quantify I'm sure it can be built for v1. But atm im glad i have v2. lol Quote
Strats Posted April 29, 2009 Posted April 29, 2009 Re: Auto quantify If you want I can post up my inventory for you. It quantifies every thing as it goes in. Unless you only want the small code. Quote
E-Studios Posted May 3, 2009 Posted May 3, 2009 Re: Auto quantify If You posted Either of the codes it would help :D Quote
AlabamaHit Posted May 3, 2009 Posted May 3, 2009 Re: Auto quantify function item_give($user, $itemid, $qty, $notid=0) { if($notid > 0) { $q=mysql_query("SELECT * FROM inventory WHERE inv_userid={$user} and inv_itemid={$itemid} AND inv_id != {$notid}"); } else { $q=mysql_query("SELECT * FROM inventory WHERE inv_userid={$user} and inv_itemid={$itemid}"); } if(mysql_num_rows($q) > 0) { $r=mysql_fetch_array($q); mysql_query("UPDATE inventory SET inv_qty=inv_qty+{$qty} WHERE inv_id={$r['inv_id']}"); } else { mysql_query("INSERT INTO inventory (inv_itemid, inv_userid, inv_qty) VALUES ({$itemid}, {$user}, {$qty})"); } } You use it like item_give(USERID, ITEMID, QTY); 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.