Mysidia Adoptables Support Forum  

Home Community Mys-Script Creative Off-Topic
Go Back   Mysidia Adoptables Support Forum > Mysidia Adoptables > Questions and Supports

Notices

Reply
 
Thread Tools Display Modes
  #1  
Old 02-27-2016, 12:01 PM
Abronsyth's Avatar
Abronsyth Abronsyth is offline
A Headache Embodied
 
Join Date: Aug 2011
Location: NY
Posts: 1,011
Gender: Male
Credits: 153,355
Abronsyth is on a distinguished road
Default

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:
<?php 

class Completeq1View extends View
     
    public function 
index(){ 
        
$mysidia Registry::get("mysidia"); 
        
$document $this->document
        
$document->setTitle("Turn in 10 Rock Cones");

            
// Allow user to complete quest if they have not yet.  
            
if ($mysidia->user->quest1 "no") {                  
                        
$document->add(new Comment("<center>Text Text Text<center>"FALSE));
                    
$this->takeItem("Rock Cone",10);
                    }        
            else{
                
$document->add(new Comment("The man furrows his brows at you, <b>sorry, no reward if you don't have any rock cones.</b>"FALSE));
                }
    }

public function 
takeItem($item$qty){
    
$mysidia Registry::get("mysidia");
    
$owned $mysidia->db->select("inventory", array("quantity"), "itemname ='{$item}' and owner ='{$mysidia->user->username}'")->fetchColumn();
    if (
$owned >= $qty){ 
        
// If the user owns $qty amount or more...
        
if ($owned == $qty){ 
            
$amount 100;
            
$mysidia->user->changecash($amount);                    
                
$document->add(new Comment("<center>You return to the scientit's camp and present the head scientist with 10 rock cones.<br>
                <b>Wow, thank you! Here are some kibs!</b><br>
                You've obtained 
{$amount} kibs!</center>"FALSE));
                
// Update that they have done the quest 
                
$mysidia->db->update("users", array("quest1" => "yes"), "username = '{$mysidia->user->username}'");
            
// If the user has exactly $qty left, delete the whole row.
             
$mysidia->db->delete("inventory""itemname='{$item}' and owner='{$mysidia->user->username}'");
            
$amount 100;
            
$mysidia->user->changecash($amount);                    
                
$document->add(new Comment("<center>You return to the scientit's camp and present the head scientist with 10 rock cones.<br>
                <b>Wow, thank you! Here are some kibs!</b><br>
                You've obtained 
{$amount} kibs!</center>"FALSE));
                
// Update that they have done the quest 
                
$mysidia->db->update("users", array("quest1" => "yes"), "username = '{$mysidia->user->username}'");
         } else {
            
// Subtract $qty from user's inventory.
            
$owned_left $owned $qty;
            
$mysidia->db->update("inventory", array("quantity" => $owned_left), "itemname ='{$item}' and owner='{$mysidia->user->username}'");  
        }
    } else {
        throw new 
Exception("Sorry, you only have {$owned} {$item}, you need {$qty}!"); 
    }
}    

    
}
?>
Edit;
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.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 10:25 PM.

Currently Active Users: 3376 (0 members and 3376 guests)
Threads: 4,081, Posts: 32,032, Members: 2,016
Welcome to our newest members, jolob.
BETA





What's New?

What's Hot?

What's Popular?


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
vBCommerce I v2.0.0 Gold ©2010, PixelFX Studios
vBCredits I v2.0.0 Gold ©2010, PixelFX Studios
Emoticons by darkmoon3636