melduk Posted April 27, 2010 Posted April 27, 2010 Hi I would like the ability to be able to use an item multiple times instead of only being able to use an item 1 at a time even if I own like 100 of an item thanks Quote
Dayo Posted April 27, 2010 Posted April 27, 2010 think there was one but i recon it would be a simple edit to the itemuse.php and inventory Quote
Equinox Posted April 27, 2010 Posted April 27, 2010 You'd need to add a quantity to the Items table, then on the item use, make a form for how many they want to use Then just do some checks if((isset($_POST['Amount'])) && ctype_digit($_POST['Amount'])) { mysql_query("UPDATE `inventory` SET `Quantity` = `Quantity` - ".$_POST['Amount']." WHERE (`userid` = ".$_SESSION['userid'].") AND (`inv_id` = ".$r['inv_id'].")"); echo 'You used '.number_format($_POST['Amount']).' of the '.htmlentities($Item['ItemName']).''; // I'm sure something like $Item was defined elsewhere } I don't care if you would do this differently, do it your way if that's the case This may not be 100% accurate, I've forgotten a lot of the McCodes setup, and this is just a quick idea of how it can be done. That's the way I'd do it Quote
Dominion Posted April 27, 2010 Posted April 27, 2010 Wrong. Itemuse works by the "inv_id", as each one is different, you'd get the error "You don't own this item" after a refresh. f5 works on mcc and still takes down the amount of that item if you have none of that item left then it tells you that Quote
gurpreet Posted April 27, 2010 Posted April 27, 2010 This could help quite a lot and I'll try to make one, I'm guessing it would run via the item names and each item in the inventory has a seperate ID. Quote
gurpreet Posted April 27, 2010 Posted April 27, 2010 $_GET['spend'] = isset($_GET['spend']) && is_string($_GET['spend']) ? strtolower(trim($_GET['spend'])) : ""; $quantity = mysql_query("SELECT i.* , u.userid from inventory i users uLEFT JOIN i.inv_userid=u.userid"); //This query probably fails, I suck at queries if(!$_GET['spend']) { echo "All of your itemuse stuff goes here except the qunatity actions"; } else if($_GET['spend'] == 'quantity') { echo "Type in the amount of {$r['itmname']} you wish to use. "; echo "<form action='itemuse.php?action=quantity2' method='post'>"; echo "<input type='text' name='quantity' /> "; echo "<input type='submit' value='Submit' />"; echo "</form>"; } else if($_GET['spend'] == 'crystals2') { $_POST['quantity'] = (float) $_POST['quantity']; if($_POST['quantity'] <= 0 || $_POST['quantity'] > {$ir['inv_qty']} //Once again, the {$r['inv_qty']} bit is probably wrong. { echo "Error, you either do not have enough {$r['itmname']}s or did not fill out the form. [url='itemuse.php?action=quantity']Back[/url]"; $h->endpage(); exit; } $TakeVotePoints = sprintf("UPDATE inventory SET inv_qty - inv_qty - %s WHERE (userid = %u)", $_POST['quantity'], $userid); $db->query($TakeVotePoints); echo "You have used {$_POST['quantity']} {$r['itmname']}(s). //Add in your itemuse codes here, I can't think atm :P } Untested and most likely won't work, but thats the basic outline. The queries are probably wrong as I'm not good using 2+ tables at once. Hope a better coder can brush this up (or recode it better 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.