Explore System - Need Help With Database Not Resetting

Forum
Last Post
Threads / Messages

NobodysHero

Co-Owner of MystFell
Member
Joined
Nov 6, 2013
Messages
144
Points
0
Mysidian Dollar
12,988
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:
<?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 ? 1 : $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 > 1 && $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));

            }
		

	}

}
?>
 
:)

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:
if ($mysidia->user->bellastday != $today) { 
        $mysidia->db->update("users", array("beltanegrab" => (0)), "username = '{$mysidia->user->username}'");
       $mysidia->user->beltanegrab = 0;         
    }
 
As seeing you all calling her aweome,i think that i'll ask help for her in the future ^u^
 

Similar threads

Users who are viewing this thread

  • Forum Contains New Posts
  • Forum Contains No New Posts

Forum statistics

Threads
4,277
Messages
33,118
Members
1,602
Latest member
BerrieMilk
BETA

Latest Threads

Top