View Single Post
  #13  
Old 12-20-2015, 02:12 PM
tahbikat's Avatar
tahbikat tahbikat is offline
Member
 
Join Date: Feb 2014
Location: Louisiana
Posts: 408
Gender: Female
Credits: 48,896
tahbikat is on a distinguished road
Default

I found a coder who fixed the issue where it wasn't resetting. He also originally noticed the 'd' not being in quotes and told me to fix that, but it still wasn't working so he took a more thorough look at it and managed to find the problem. I'll post the revised code. (: Credits to blue for the fix. Works like a charm now. This system is a big part of my site! Love it. ^^

Keep in mind for anyone who uses it, the items, currency, adopts, etc parts aren't included. Put them after the "$random = rand(1,1506); " part. Also you may need to edit some parts of it like the $item part and such, as that's used on my site.

PHP Code:
<?php

class Explorearea1View extends View{
    
    public function 
index(){
        
$mysidia Registry::get("mysidia");
        
$document $this->document;
            
$document->setTitle("Exploring Cold Biomes"); 
            
$item "Snow Boots";
        
$hasitem $mysidia->db->select("inventory", array("quantity"), "itemname ='{$item}' and owner='{$mysidia->user->username}'")->fetchColumn();
        
        if(
$hasitem){ 
            
$today date("d"); // Day of the month
            
            // Reset explore counter if the last recorded exploration was on a different day than today:
            
$reset $mysidia->user->lastday != $today

            
// Allow user to explore if they are under the limit or if reset condition is true. 
            
if ($mysidia->user->exploretimes <= 50 || $reset) {  
                
// Update the last day that they explored to today
                
$mysidia->db->update("users", array("lastday" => $today), "username = '{$mysidia->user->username}'");

                
// If $reset condition was true, reset the count to 1, otherwise increment the existing count. 
                
$updatedExploreTimes $reset $mysidia->user->exploretimes 1
                
                
$mysidia->db->update("users", array("exploretimes" => ($updatedExploreTimes)), "username = '{$mysidia->user->username}'"); 
                 
            
$random rand(1,1506);




            } else { 
// Past limit
                
$document->add(new Comment("It seems you have explored too much today, why don't you take a rest until tomorrow?"FALSE));
            }   
        } else { 
// Lacking item
                
$document->add(new Comment("Woah there! You need a pair of Snow Boots in order to explore. Wouldn't wanna get frostbite! Why don't you go purchase some from Gerolt's first?"FALSE));
        }
    }

}
?>
Reply With Quote