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 04-16-2016, 11:58 AM
Abronsyth's Avatar
Abronsyth Abronsyth is offline
A Headache Embodied
 
Join Date: Aug 2011
Location: NY
Posts: 1,011
Gender: Male
Credits: 117,885
Abronsyth is on a distinguished road
Default Help Debugging Quest Code

Hello!

Below is a chunk of my quest code. It is supposed to remove 10 rock cones if the user has 10 and has not already completed the quest. If they have completed the quest it is supposed to simply tell them they no longer need rock cones. However, my users have reported that even when they've already done it they are still losing rock cones out of their inventory (and not receiving a reward for it). Does anyone see an issue in this chunk of code that would result in them having 10 rock cones taken out even after already doing it?
PHP Code:
    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. 
        
$notdone $mysidia->db->select("users", array("quest1"), "quest1='no' and username='{$mysidia->user->username}'")->fetchColumn();            
        
$takeItem $this->takeItem("Rock Cone"10);

        if (
$notdone){
            if (
$takeItem){
                
$mysidia->db->update("users", array("quest1" => "yes"), "username = '{$mysidia->user->username}'");
                
$amount 150;
                
$mysidia->user->changecash($amount); 
                
$document->add(new Comment("Thank you for bringing me those Rock Cones!<br>
                You've recieve 
$amount kibs as a thankyou!"FALSE));
                
            } else {
                
$document->add(new Comment("Hey, this isn't enough Rock Cones!"FALSE));
            } 
        }
        else {
            
$document->add(new Comment("Sorry, we don't need anymore rock cones."FALSE));
        }
    } 
__________________
My Mods Site (1.3.4, 2020 Mods)
Reply With Quote
  #2  
Old 04-16-2016, 03:23 PM
Kyttias's Avatar
Kyttias Kyttias is offline
Premium Member
 
Join Date: Jan 2014
Posts: 857
Gender: Unknown/Other
Credits: 91,453
Kyttias is on a distinguished road
Default

Well, does $notdone hold the boolean value for true/false or a string with the words either "true" or "false" in it? There's a big difference. Try being more explicit with the value you're looking to fill.

PHP Code:
if ($notdone == "true"){ /* ... */ } else { /* ... */ 
Otherwise it'll just look to see if the variable holds any contents at all. Of course it does, so it runs the first statement. A string with the word "false" in it is still a variable with contents in it so it's always going to return a boolean of true. Variables pulled from the database are not explicitly boolean by default. You could always try storing values as 0 or 1 and they would register better, or, change the column type in the database.
__________________
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; 04-16-2016 at 03:26 PM.
Reply With Quote
Reply


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 03:23 AM.

Currently Active Users: 949 (0 members and 949 guests)
Threads: 4,080, Posts: 32,024, 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 - 2024, vBulletin Solutions Inc.
vBCommerce I v2.0.0 Gold ©2010, PixelFX Studios
vBCredits I v2.0.0 Gold ©2010, PixelFX Studios
Emoticons by darkmoon3636