#1
|
||||
|
||||
Check quantity of an item
I'm working on building very simple quests and I'm wondering if anyone knows how to ask the database to check if the quantity of a specific item a user has is, say 10 or more?
Edit: And then also remove the specified quantity of that item from the users inventory? So say it's a quest and they need to turn in 10 rocks, first it verifies that they have 10 or more rocks, and then it removes 10 rocks from their inventory if they indeed have 10 or more. Thank you, -Abron
__________________
My Mods Site (1.3.4, 2020 Mods) Last edited by Abronsyth; 02-27-2016 at 10:31 AM. |
#2
|
||||
|
||||
How about a function like this?
PHP Code:
__________________
Please do not contact me directly outside of Mysidia.
I also cannot troubleshoot code more than two years old - I legit don't remember it. |
#3
|
||||
|
||||
OK I know I did something terribly unintelligent to get this error;
Fatal error: Uncaught exception 'Exception' with message 'Sorry, you only have Rock Cone, you need 10!' in /home/arieng/catisserie.net/view/completeq1view.php:48 Stack trace: #0 /home/arieng/catisserie.net/view/completeq1view.php(13): Completeq1View->takeItem('Rock Cone', 10) #1 /home/arieng/catisserie.net/classes/class_frontcontroller.php(100): Completeq1View->index() #2 /home/arieng/catisserie.net/index.php(74): FrontController->render() #3 /home/arieng/catisserie.net/index.php(78): IndexController::main() #4 {main} thrown in /home/arieng/catisserie.net/view/completeq1view.php on line 48 I'm sure this will make you cringe to look at but this is the file thus far; PHP Code:
OK, may be because I didn't actually define $qty at any point...not really sure how to, though @_@ I know that you can see if a user owns a certain item, but not sure how to define $qty to check how many of that item they own.
__________________
My Mods Site (1.3.4, 2020 Mods) Last edited by Abronsyth; 02-27-2016 at 12:06 PM. |
#4
|
||||
|
||||
No, you did it right, with takeItem("Rock Cone",10); that 10 is defining $qty in the function. I wasn't entirely sure on how to construct the end of the function... rather than
PHP Code:
PHP Code:
PHP Code:
__________________
Please do not contact me directly outside of Mysidia.
I also cannot troubleshoot code more than two years old - I legit don't remember it. |
#5
|
||||
|
||||
OK, thank you! So no longer getting the error, but the text doesn't want to actually appear on the page XD
Rather it's appearing right above all of the page, oops!
__________________
My Mods Site (1.3.4, 2020 Mods) |
#6
|
||||
|
||||
Yeah, I figured, that's what an echo does. You'll have to decide what you want to actually be doing as a result. It all depends on what you actually wanted to be doing with the function...?
I would suggest this: PHP Code:
PHP Code:
__________________
Please do not contact me directly outside of Mysidia.
I also cannot troubleshoot code more than two years old - I legit don't remember it. Last edited by Kyttias; 02-27-2016 at 05:54 PM. |
Thread Tools | |
Display Modes | |
|
|
What's New? |
What's Hot? |
What's Popular? |