Mysidia Adoptables Support Forum

Mysidia Adoptables Support Forum (http://www.mysidiaadoptables.com/forum/index.php)
-   Questions and Supports (http://www.mysidiaadoptables.com/forum/forumdisplay.php?f=18)
-   -   Explore System - Need Help With Database Not Resetting (http://www.mysidiaadoptables.com/forum/showthread.php?t=5100)

NobodysHero 04-01-2016 09:10 AM

Explore System - Need Help With Database Not Resetting
 
Okay, I saw the fix in this thread, but I still can't get it to reset. Can someone show me in my code where it's wrong? I'm really having a hard time here. This is the code for my Egg Hunt game that I made for a on-site holiday, I added extra columns in the database, just like it says for the explore pages, then modified ONLY those parts of the code.

The regular explore pages don't reset either, so showing me what I did wrong here will also help me see where I went wrong on the others. Thanks!


PHP Code:

<?php

class beltanegrabView extends View{
    
    public function 
index(){
        
$mysidia Registry::get("mysidia");
        
$document $this->document;
            
$document->setTitle("Welcome to the Beltane Egg Hunt!");  
                
$reset $mysidia->user->lastday != $today;  
                
$updatedExploreTimes $reset $mysidia->user->exploretimes 1;  
        
$today date("d");
        if (
$mysidia->user->bellastday != $today) {
        
$mysidia->db->update("users", array("beltanegrab" => (0)), "username = '{$mysidia->user->username}'");        
        }

        
$mysidia->db->update("users", array("bellastday" => $today), "username = '{$mysidia->user->username}'");
        
$mysidia->db->update("users", array("beltanegrab" => ($mysidia->user->beltanegrab 1)), "username = '{$mysidia->user->username}'");  
        if (
$mysidia->user->beltanegrab <= 12) {  
            
$random rand(1,1000);
            


            if(
$random && $random 49){
                
$species "Ruadh Butterfly";
                
$newadopt = new StockAdopt($species);
                
$newadopt->append($mysidia->user->username);
                
$adoptIMG $mysidia->db->select("adoptables", array("eggimage"), "id = '25'")->fetchColumn();
                
$document->add(new Comment("<center><img src='$adoptIMG' alt='$species IMG' /><br> Pretty, pretty <b>$species</b>! Flutter, flutter, flutter!</center>"FALSE));
            }
            elseif(
$random >= 50 && $random <= 99){
                
$amount rand(50,200000);
                
$mysidia->user->changecash($amount); 
                
$document->add(new Comment("<center>Oh look! You found $amount tyleans!</center>"FALSE)); 
            }
            if(
$random >= 100 && $random <= 149){
                
$species "Corcra Butterfly";
                
$newadopt = new StockAdopt($species);
                
$newadopt->append($mysidia->user->username);
                
$adoptIMG $mysidia->db->select("adoptables", array("eggimage"), "id = '26'")->fetchColumn();
                
$document->add(new Comment("<center><img src='$adoptIMG' alt='$species IMG' /><br> Good thing you brought your net! The $species</b> is quite the flier!</center>"FALSE));
            }  
            if(
$random >= 150 && $random <= 249){
                
$species "Oraiste Butterfly";
                
$newadopt = new StockAdopt($species);
                
$newadopt->append($mysidia->user->username);
                
$adoptIMG $mysidia->db->select("adoptables", array("eggimage"), "id = '27'")->fetchColumn();
                
$document->add(new Comment("<center><img src='$adoptIMG' alt='$species IMG' /><br> Oh look! You found a <b>$species!</b> OHOH! There it goes! GRAB IT!</center>"FALSE));
            }  
            if(
$random >= 250 && $random <= 350){
                
$item "Cearc Egg";
                
$qty 1;
                
$newitem = new StockItem($item);
                
$newitem->append($qty$mysidia->user->username);  
                
$itemIMG $mysidia->db->select("items", array("imageurl"), "id = '50'")->fetchColumn();
                
$document->add(new Comment("<center><img src='$itemIMG' alt='$item IMG' /><br>Poor little abandoned <b>$item</b>. It might not hatch, but it's still cute.</center>"FALSE));
            }
            if(
$random >= 351 && $random <= 450){
                
$species "Lemon Cearc";
                
$newadopt = new StockAdopt($species);
                
$newadopt->append($mysidia->user->username);
                
$adoptIMG $mysidia->db->select("adoptables", array("eggimage"), "id = '35'")->fetchColumn();
                
$document->add(new Comment("<center><img src='$adoptIMG' alt='$species IMG' /><br> Oh, I can't wait til it hatches! The <b>$species</b> is my favorite! </center>"FALSE));
            }
            if(
$random >= 451 && $random <= 500){
                
$species "Black Cherry Cearc";
                
$newadopt = new StockAdopt($species);
                
$newadopt->append($mysidia->user->username);
                
$adoptIMG $mysidia->db->select("adoptables", array("eggimage"), "id = '39'")->fetchColumn();
                
$document->add(new Comment("<center><img src='$adoptIMG' alt='$species IMG' /><br> Oh, I can't wait til it hatches! The <b>$species</b> is my favorite! </center>"FALSE));
                }  
            if(
$random >= 501 && $random <= 550){
                
$species "Licorice Cearc";
                
$newadopt = new StockAdopt($species);
                
$newadopt->append($mysidia->user->username);
                
$adoptIMG $mysidia->db->select("adoptables", array("eggimage"), "id = '36'")->fetchColumn();
                
$document->add(new Comment("<center><img src='$adoptIMG' alt='$species IMG' /><br>The <b>$species</b> is like the ugly duckling, only it's a Cearc and it's cute!</center>"FALSE));
            }
            if(
$random >= 551 && $random <= 600){
                
$species "Blueberry Cearc";
                
$newadopt = new StockAdopt($species);
                
$newadopt->append($mysidia->user->username);
                
$adoptIMG $mysidia->db->select("adoptables", array("eggimage"), "id = '37'")->fetchColumn();
                
$document->add(new Comment("<center><img src='$adoptIMG' alt='$species IMG' /><br>Looking at the <b>$species</b> chick makes me want some jellybeans!</center>"FALSE));
            }
            if(
$random >= 601 && $random <= 650){
                
$species "Kiwi Cearc";
                
$newadopt = new StockAdopt($species);
                
$newadopt->append($mysidia->user->username);
                
$adoptIMG $mysidia->db->select("adoptables", array("eggimage"), "id = '38'")->fetchColumn();
                
$document->add(new Comment("<center><img src='$adoptIMG' alt='$species IMG' /><br>Green? Weird... Maybe it's radioactive! Oh, no wait. It's just a <b>$species</b>!</center>"FALSE));
            }
            if(
$random >= 651 && $random <= 700){
                
$species "Coconut Cearc";
                
$newadopt = new StockAdopt($species);
                
$newadopt->append($mysidia->user->username);
                
$adoptIMG $mysidia->db->select("adoptables", array("eggimage"), "id = '40'")->fetchColumn();
                
$document->add(new Comment("<center><img src='$adoptIMG' alt='$species IMG' /><br>Awwww! This <b>$species</b> is nearly as white as its shell!</center>"FALSE));
            }
            if(
$random >= 701 && $random <= 750){
                
$species "Oyster";
                
$newadopt = new StockAdopt($species);
                
$newadopt->append($mysidia->user->username);
                
$adoptIMG $mysidia->db->select("adoptables", array("eggimage"), "id = '145'")->fetchColumn();
                
$document->add(new Comment("<center><img src='$adoptIMG' alt='$species IMG' /><br>OHOHOH! Look, it's a <b>$species</b>! Wait... What's a $species have to do with Beltane? Meh.</center>"FALSE));
            }
            if(
$random >= 751 && $random <= 800){
                
$species "Eggshell Velociraptor";
                
$newadopt = new StockAdopt($species);
                
$newadopt->append($mysidia->user->username);
                
$adoptIMG $mysidia->db->select("adoptables", array("eggimage"), "id = '159'")->fetchColumn();
                
$document->add(new Comment("<center><img src='$adoptIMG' alt='$species IMG' /><br>This <b>$species</b> jumped right out! WHOA!</center>"FALSE));
            }
            if(
$random >= 801 && $random <= 850){
                
$species "One Cereus Bunny";
                
$newadopt = new StockAdopt($species);
                
$newadopt->append($mysidia->user->username);
                
$adoptIMG $mysidia->db->select("adoptables", array("eggimage"), "id = '158'")->fetchColumn();
                
$document->add(new Comment("<center><img src='$adoptIMG' alt='$species IMG' /><br>Awwww. Did you know <b>$species</b> was in there? Don't look at me! I didn't know either!</center>"FALSE));
            }
            if(
$random >= 851 && $random <= 899){
                
$species "Cereus Fox";
                
$newadopt = new StockAdopt($species);
                
$newadopt->append($mysidia->user->username);
                
$adoptIMG $mysidia->db->select("adoptables", array("eggimage"), "id = '157'")->fetchColumn();
                
$document->add(new Comment("<center><img src='$adoptIMG' alt='$species IMG' /><br>What a sly and handsome <b>$species</b> you've found!</center>"FALSE));
            }
            }
        if(
$random >= 900 && $random <= 999){
$document->add(new Comment("<center>Nothing in your egg, huh? Guess you better crack open another one!<br><br> 
<a href='/beltanegrab'>Explore Again</a><br><br><img src='http://i.imgur.com/6EjkLtI.png' /></center>"
FALSE));
            }   
            elseif(
$random == 1000){
                
$species "Chasmic Sheep";
                
$newadopt = new StockAdopt($species);
                
$newadopt->append($mysidia->user->username);
                
$adoptIMG $mysidia->db->select("adoptables", array("eggimage"), "id = '156'")->fetchColumn();
                
$document->add(new Comment("<center><img src='$adoptIMG' alt='$species IMG' /><br> MY GOODNESS! You've found a $species! LOOK HOW FLUFFY!</center>"FALSE));
            }
            else{
            
            
$document->add(new Comment(" <br><center><b>You can only search 12 eggs a day. If this is the only message you see, then you have no more tries.</b></center>"FALSE));
            
$document->add(new Comment("<br><center>Click on an egg below to try another one! Click the nest or refresh.<br><a href='/beltanegrab'><img width='50%' src='http://i1166.photobucket.com/albums/q610/MystFell/SHATTEREDMIND/Google%20Drive/Site_Assets/Web%20Assets/Beltane/BirdNest_Eggs_zpsa2b593d0.png'</a>></center>"FALSE));

            }
        

    }

}
?>


RestlessThoughts 04-05-2016 08:47 AM

:)
 
The main issue is that even though you update the table to be 0, $mysidia->user->beltanegrab still holds the old, original value. So you're updating the table to 0, then setting it back to the old value + 1.

So the easiest patch would be to set $mysidia->user->beltanegrab to 0 when you update the table to be 0. Then the next check of $mysidia->user->beltanegrab later down the script will be correctly reset and allow players to continue.
PHP Code:

if ($mysidia->user->bellastday != $today) { 
        
$mysidia->db->update("users", array("beltanegrab" => (0)), "username = '{$mysidia->user->username}'");
       
$mysidia->user->beltanegrab 0;         
    } 


NobodysHero 04-06-2016 09:01 AM

Restless... I'm quickly becoming your biggest fan. <3

Ittermat 04-06-2016 11:33 AM

I Know restless is awesome! <3

LUC1G07CH1 04-10-2016 10:39 AM

As seeing you all calling her aweome,i think that i'll ask help for her in the future ^u^


All times are GMT -5. The time now is 06:09 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.