Mysidia Adoptables Support Forum  

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

Notices

Reply
 
Thread Tools Display Modes
  #11  
Old 12-20-2015, 11:44 AM
Abronsyth's Avatar
Abronsyth Abronsyth is offline
A Headache Embodied
 
Join Date: Aug 2011
Location: NY
Posts: 1,011
Gender: Male
Credits: 133,528
Abronsyth is on a distinguished road
Default

Alright, so for some reason user exploretimes are not resetting each day, instead it's simply been accumulating over time, even when it's been over 24 hours. Is anyone else having this issue?
Excerpt from my "explorecentralview.php"
PHP Code:
    public function index(){
        
$mysidia Registry::get("mysidia");
        
$document $this->document;
            
$document->setTitle("Exploring Central Forest");
            
$document->add(new Comment("<center>You have taken {$mysidia->user->exploretimes} of 10,000 steps.</center>"FALSE));    
        
$today date(d);
        if (
$mysidia->user->lastday != $today) {
        
$mysidia->db->update("users", array("exploretimes" => (0)), "username = '{$mysidia->user->username}'");        
        }

        
$mysidia->db->update("users", array("lastday" => $today), "username = '{$mysidia->user->username}'");
        
$mysidia->db->update("users", array("exploretimes" => ($mysidia->user->exploretimes 1)), "username = '{$mysidia->user->username}'");  
        if (
$mysidia->user->exploretimes <= 10000) {  
            
$random rand(1,100); 
__________________
My Mods Site (1.3.4, 2020 Mods)
Reply With Quote
  #12  
Old 12-20-2015, 01:35 PM
Kyttias's Avatar
Kyttias Kyttias is offline
Premium Member
 
Join Date: Jan 2014
Posts: 857
Gender: Unknown/Other
Credits: 111,366
Kyttias is on a distinguished road
Default

...Nothing there looks wrong, in theory. Except that an else statement should be being used, probably, for clarity's sake.

That and it should be date('d'); not date(d);. Using d without quotes means you're looking for a constant by the name of d that you have not set, rather than it using it's parameter - it knows what 'd' is, but not d.

Therefore it's not checking today's date at all.

So it's really never resetting the counter. When it sees "If the last day is not ????ERROR????, do this" it will just ignore it, since... it's not a valid question to be asking. Because true/false things have to make sense. Not making sense doesn't equal false (or true) so it ignores it and moves on, never actually resetting anything. And it'll continue to run the code afterward as normal.

It might even be reading it as "If last day is not set" because it probably fills the error in with nothing. It's like a hanging sentence. If last day is not................? Not what? Well it is, it's a thing that exists, so continue! ...Computers, man.

It's a simple mistake, no biggie. Is this the fix we're looking for?
__________________
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; 12-20-2015 at 01:38 PM.
Reply With Quote
  #13  
Old 12-20-2015, 03:12 PM
tahbikat's Avatar
tahbikat tahbikat is offline
Member
 
Join Date: Feb 2014
Location: Louisiana
Posts: 408
Gender: Female
Credits: 57,816
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
  #14  
Old 12-20-2015, 03:37 PM
Kyttias's Avatar
Kyttias Kyttias is offline
Premium Member
 
Join Date: Jan 2014
Posts: 857
Gender: Unknown/Other
Credits: 111,366
Kyttias is on a distinguished road
Default

There are definitely still potential issues that could use some polishing to take care of tiny caveats - say you last explored March 20th, and somehow the next time you came around to do that was April 20th, out of some ironic inconvenience?
__________________
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.
Reply With Quote
  #15  
Old 12-20-2015, 04:11 PM
tahbikat's Avatar
tahbikat tahbikat is offline
Member
 
Join Date: Feb 2014
Location: Louisiana
Posts: 408
Gender: Female
Credits: 57,816
tahbikat is on a distinguished road
Default

Hahaha now that would be a little funny. :x
Reply With Quote
  #16  
Old 12-20-2015, 05:26 PM
Abronsyth's Avatar
Abronsyth Abronsyth is offline
A Headache Embodied
 
Join Date: Aug 2011
Location: NY
Posts: 1,011
Gender: Male
Credits: 133,528
Abronsyth is on a distinguished road
Default

Thank you for sharing the fix! My users and I appreciate it <3

To fix that issue, Kyttias, couldn't one just also add in a month counter along with day?
__________________
My Mods Site (1.3.4, 2020 Mods)
Reply With Quote
  #17  
Old 12-20-2015, 05:40 PM
Kyttias's Avatar
Kyttias Kyttias is offline
Premium Member
 
Join Date: Jan 2014
Posts: 857
Gender: Unknown/Other
Credits: 111,366
Kyttias is on a distinguished road
Default

Probably, so long as lastday is being stored with that info. ^^
__________________
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.
Reply With Quote
  #18  
Old 12-20-2015, 11:42 PM
Abronsyth's Avatar
Abronsyth Abronsyth is offline
A Headache Embodied
 
Join Date: Aug 2011
Location: NY
Posts: 1,011
Gender: Male
Credits: 133,528
Abronsyth is on a distinguished road
Default

So with this feature does anyone know how/if I would be able to make it so that instead of automatically adding found cats/items to a user's account it would give them the option to either take or leave it?
__________________
My Mods Site (1.3.4, 2020 Mods)
Reply With Quote
  #19  
Old 12-23-2015, 08:14 PM
tahbikat's Avatar
tahbikat tahbikat is offline
Member
 
Join Date: Feb 2014
Location: Louisiana
Posts: 408
Gender: Female
Credits: 57,816
tahbikat is on a distinguished road
Default

Hmm, could anyone help me with something?

I'm setting up a new pet profile field called "Obtained from" which basically says where the adoptable originated (adopt page, shop, exploring, etc) however this code uses 'StockAdopt' to generate adopts, which is a shop adopt. I want to use a different type there so that I can say the adoptable came from the "Wilderness"(exploring) and not the market.

I tried replacing 'StockAdopt' with 'Adopt' and 'Adoptable' but it's not working, lol. Anyone have any clues?

EDIT: Nvm, of course I find a solution right after posting woops.

Last edited by tahbikat; 12-23-2015 at 08:31 PM.
Reply With Quote
  #20  
Old 03-30-2016, 08:15 PM
NobodysHero's Avatar
NobodysHero NobodysHero is offline
Co-Owner of MystFell
 
Join Date: Nov 2013
Posts: 144
Gender: Female
Credits: 21,813
NobodysHero is on a distinguished road
Default Re: Explore System - Help Please!

Okay, I saw the fix further in the 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));

            }
        

    }

}
?>
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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Quest- Explore System (Open Source) squiggler Tutorials and Tips 4 07-23-2020 01:07 PM
How to create an image map collierox Tutorials and Tips 3 03-13-2018 05:11 AM
Explore Help? cailynmae Questions and Supports 7 03-30-2017 12:37 AM
Help Create This? Abronsyth Templates and Themes 16 10-24-2011 04:05 PM
How to create a a battle system ,shop and currency?? SieghartZeke Questions and Supports 9 11-02-2009 01:15 AM


All times are GMT -5. The time now is 06:00 PM.

Currently Active Users: 733 (0 members and 733 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 - 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