Mysidia Adoptables Support Forum

Mysidia Adoptables Support Forum (http://www.mysidiaadoptables.com/forum/index.php)
-   Tutorials and Tips (http://www.mysidiaadoptables.com/forum/forumdisplay.php?f=27)
-   -   How To Create an Explore System in Mys. 1.3.4 (http://www.mysidiaadoptables.com/forum/showthread.php?t=4827)

cailynmae 04-21-2015 11:07 AM

How To Create an Explore System in Mys. 1.3.4
 
How to Create an Explore System


"In this tutorial we will go over how you can create an exploration system. It will start with a few basic questions and answers, and then will move onto the acutal coding and tutorial.


Questions and Answers

What sort of exploration system are we going to be making?
We'll be making a basic system where your users can explore different locations and have different chances of finding different pets and items.

What are the features of this exploration system?
Here's a list:
  • Exploring different areas
  • Chances of finding certain pets, items, amounts of currency, or nothing
  • Allowing a user to explore a certain area only if they have a certain item
  • Allowing a user to explore a certain area only if they have a premium membership
  • Allowing a user to explore a certain area only if they are in a certain usergroup
  • Allowing a user to explore an area a certain number of times each day
  • And maybe more that I have forgotten about


Okay then! Tell me anything else I might need to know and then can you get on with the tutorial?
Well, I use this exploration system on my own site. Also, certain bits of code(pretty much the MySQL bits) I learned from Kyttias(Seriously helpful member who has earned her premium membership many times over), but the basic idea of what I needed to do I came up with myself. Anyway, I feel like I should share this script with the community, because all the other exploration systems I have seen on here either are basically just interactive stories, not informative enough, or outdated. This script is tried and tested for Mys. 1.3.4, but not for anything else. Let me know how it works for older things! Oh yeah. I can start the tutorial now.


Tutorial and Script

Step One - Creating the explore pages:

We need to create the explore pages before we can do anything. First, let's create the explore.php page. Put this inside:
Code:

<?php

class ExploreController extends AppController{

    public function __construct(){
        parent::__construct("member");       
    }
       
        public function index(){
                $mysidia = Registry::get("mysidia");
        }
}
?>

Now, go to the view folder and create the exploreview.php page. Put this in it:
Code:

<?php
class ExploreView extends View{

    public function index(){
        $mysidia = Registry::get("mysidia");
        $document = $this->document;       
        $document->setTitle("Explore");   
        $document->add(new Comment("Choose a location that you wish to explore.", FALSE));

    }bl
   
}
?>

We'll come back to this page later.

Step Two - Modifying the database

We need to modify the database in order for this to work. You will need to add two columns to the adopts_users table. The first one will be named lastday. Its type will be VARCHAR(20), Collation utf8_unicode_ci, and Default 0. The second will be named exploretimes, with type INT(20). They should look something like this when you are creating them:
http://imaginea.net/pics/sqlexample.png
If you want to have premium members, add a column in adopts_users_status named premium, type VARCHAR(20), Collation utf8_unicode_ci, and Default 'No'.

Step Three - Creating the exploration areas

For each area a user can explore, create a page called explore[put area name here].php and explore[put area name here].php. For the purpose of this tutorial, we'll just make two areas: Area 1 and Area 2. We'll create explorearea1.php and explorearea2.php. In them we'll put:
Code:

<?php

class Explorearea1Controller extends AppController{

    public function __construct(){
        parent::__construct("member");       
    }
       
        public function index(){
                $mysidia = Registry::get("mysidia");
        }
}
?>

in explorearea1.php, and
Code:

<?php

class Explorearea2Controller extends AppController{

    public function __construct(){
        parent::__construct("member");       
    }
       
        public function index(){
                $mysidia = Registry::get("mysidia");
        }
}
?>

in explorearea2.php. Next, we'll create explorearea1view.php and explorearea2view.php. First we'll put
Code:

<?php

class Explorearea1View extends View{
       
        public function index(){
            $mysidia = Registry::get("mysidia");
                $document = $this->document;
                $document->setTitle("Exploring Area 1"); 
                $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 <= 5) { 
                        $random = rand(1,100);

                        if($random > 1 && $random < 20){
                                $species = "Common Species";
                                $newadopt = new StockAdopt($species);
                                $newadopt->append($mysidia->user->username);
                                $document->add(new Comment("Oh look! You found a $species! It's pretty common.", FALSE));
                        }
                        elseif($random >= 21 && $random <= 30){
                                $amount = rand(5,20);
                                $mysidia->user->changecash($amount);
                                $document->add(new Comment("Oh look! You found $amount cash!", FALSE));
                        }
                        elseif($random >= 31 && $random <= 40){
                                $item = "Item";
                                $qty = 1;
                                $newitem = new StockItem($item);
                                $newitem->append($qty, $mysidia->user->username); 
                                $document->add(new Comment("Oh look! You found a <b>$item</b>!", FALSE));
                        }
                        if($random >= 41 && $random <= 60){
                                $species = "Another Common Species";
                                $newadopt = new StockAdopt($species);
                                $newadopt->append($mysidia->user->username);
                                $document->add(new Comment("Oh look! You found a $species! It's pretty common.", FALSE));
                        }
                        if($random >= 61 && $random <= 70){
                                $species = "Uncommon Species";
                                $newadopt = new StockAdopt($species);
                                $newadopt->append($mysidia->user->username);
                                $document->add(new Comment("Oh look! You found a $species! It's uncommon.", FALSE));
                        }
                        if($random >= 71 && $random <= 75){
                                $species = "Rare Species";
                                $newadopt = new StockAdopt($species);
                                $newadopt->append($mysidia->user->username);
                                $document->add(new Comment("Oh look! You found a $species! It's rare and hard to find.", FALSE));
                        }
                        if($random >= 76 && $random <= 80){
                                $item = "Item";
                                $qty = 1;
                                $newitem = new StockItem($item);
                                $newitem->append($qty, $mysidia->user->username); 
                                $document->add(new Comment("Oh look! You found a <b>$item</b>!", FALSE));
                        }
                        if($random >= 81 && $random <= 90){
                                $item = "Rock";
                                $qty = 1;
                                $newitem = new StockItem($item);
                                $newitem->append($qty, $mysidia->user->username); 
                                $document->add(new Comment("Oh look! You found a <b>$item</b>!", FALSE));
                        }
                        if($random >= 91 && $random <= 99){
                                $document->add(new Comment("You didn't find anything. Better luck next time.", FALSE));
                        }
                        elseif($random == 100){
                                $species = "Very Rare Species";
                                $newadopt = new StockAdopt($species);
                                $newadopt->append($mysidia->user->username);
                                $document->add(new Comment("Oh look! You found a$species! Wow, it's really rare.", FALSE));
                        }
                        else{
                        $document->add(new Comment("Oops! Something went wrong.", FALSE));
                        }
                }
                else{
                $document->add(new Comment("It seems you have explored too much today, why don't you take a rest?", FALSE));
                } 

        }

}
?>

in explorearea1.php. We'll put the same in explorearea2.php, but instead we'll replace class Explorearea1View extends View{ with class Explorearea2View extends View{, and $document->setTitle("Exploring Area 1"); with $document->setTitle("Exploring Area 2");.

Step Four - Choosing the chances and types of pets and items

You probably want to decide how often a pet or item or currency pops up. You also probably wish to decide which pets or items can be found. So, I'll show you the code for obtaining a pet:
Code:

                        if($random >= 41 && $random <= 60){
                                $species = "Another Common Species";
                                $newadopt = new StockAdopt($species);
                                $newadopt->append($mysidia->user->username);
                                $document->add(new Comment("Oh look! You found a $species! It's pretty common.", FALSE));
                        }

This bit determines the rarity out of a hundred: if($random >= 41 && $random <= 60){. This means that if the random number picked is in between 41 and 60, it will give the user that pet. It also means it has a 1 in 5 chance of getting picked. You can change the two numbers to grow or shrink the range. $species determines which species will be found, and $document->add(new Comment("Oh look! You found a $species! It's pretty common.", FALSE)); can be modified to determine what the page says.
Code:

                        if($random >= 81 && $random <= 90){
                                $item = "Rock";
                                $qty = 1;
                                $newitem = new StockItem($item);
                                $newitem->append($qty, $mysidia->user->username); 
                                $document->add(new Comment("Oh look! You found a <b>$item</b>!", FALSE));
                        }

This is the code for obtaining an item. Everything is as before, except you change $item to determine which item is given, and $qty to determine how much of that item is given.
Code:

                        elseif($random >= 21 && $random <= 30){
                                $amount = rand(5,20);
                                $mysidia->user->changecash($amount);
                                $document->add(new Comment("Oh look! You found $amount cash!", FALSE));
                        }

This is the code for giving a user some currency. Everything is as before, except you change $amount to determine the amount of currency that is given.
Code:

                        if($random >= 91 && $random <= 99){
                                $document->add(new Comment("You didn't find anything. Better luck next time.", FALSE));
                        }

This is the code for finding nothing. Poor explorer.

Step Five - Restrictions

Here's how to input a restriction: Right after the $document->setTitle(""); line, put the first part of the restriction code. Then, right after the else{
$document->add(new Comment("It seems you have explored too much today, why don't you take a rest?", FALSE));
} lines, paste the second part of the restriction code.

Item Restriction: This will only let a user explore in that area if they have a specific item.
First Part:
Code:

$item = "[put item name here]";
                $hasitem = $mysidia->db->select("inventory", array("quantity"), "itemname ='{$item}' and owner='{$mysidia->user->username}'")->fetchColumn();
                if($hasitem){

Second Part:
Code:

}
                else{
                        $document->add(new Comment("[put text here]", FALSE));
                }

Premium Restriction: This will only let a user explore in a certain area if they have a premium membership. NOTE: This only works if you followed the second part of the database modifications I mentioned above.
First Part:
Code:

                if($mysidia->user->status->premium == "yes"){
Second Part:
Code:

                else{
                        $document->add(new Comment("Whoops, looks like you aren't a premium member. Only premium members can explore here.", FALSE));
                }

More restrictions may come soon!


Sixth Part: Links and/or image maps

Now you need to go back to the exploreview.php file and add this right after the $document->add(new Comment("Choose a location that you wish to explore.", FALSE)); line:
Code:

$document->add(new Comment(""));
Inside the quotes add the code for your form of links to the different area pages. For example, Area 1, or area1.php, would need something that linked to yoursite.com/area1. Make sure to replace all " within the quotes with ', or you'll have some problems.

Now save everything and visit yoursite.com/explore and look around! You've coded an explore system!

Let me know if you have any issues with this. Let me know if this was helpful! Thank you and you're welcome!

draugluin 04-28-2015 08:26 AM

Hey,

I've tried this. It's really good. :smile::smile::smile:

cailynmae 04-28-2015 08:41 AM

Thanks! I'm glad you like it.

tahbikat 12-03-2015 03:46 AM

Really excited to get this working on my site, but when I do everything above and go to explore, it gives me this error:

Fatal error: Class 'Explorearea1View' not found in /home/mysgardia/public_html/classes/class_controller.php on line 135



Can someone help me? Not sure when the OP will see this. :c

EDIT: Nvm, I fixed it! However, everytime I explore, it gives me the item or adoptable, but always says "Ooops! Something went wrong." after the comment, so I just removed that part.

Distortion 12-03-2015 04:10 PM

Is there a way to add an image to every explore encounter?

tahbikat 12-03-2015 04:27 PM

Quote:

Originally Posted by Distortion (Post 33041)
Is there a way to add an image to every explore encounter?

I was thinking the same. I'd just put the image of the egg (or whatever your lvl0 image is) for each adopt in the comments.

So for example take this:

PHP Code:

            if($random >= 41 && $random <= 60){
                
$species "Another Common Species";
                
$newadopt = new StockAdopt($species);
                
$newadopt->append($mysidia->user->username);
                
$document->add(new Comment("Oh look! You found a $species! It's pretty common."FALSE));
            } 

and replace the $document->add(new Comment( part with this:

PHP Code:

$document->add(new Comment("Oh look! You found a <img src='imglinkhere' /> $species egg! It's pretty common."FALSE)); 


Make sure you use only 'single' quotes for any code instead of the "double" quotes. Also, you can experiment with image placement. So if you want it before the comment and centered on its own line just add some br tags after it with center tags around. Likewise, do the same for items, currency, and when a user turns up with nothing.

I also found it quite helpful to add a link called (Continue Exploring) to the same explorearea1 page after the comment, so that instead of having to refresh the page, a user just clicks it to continue exploring.

I'm gonna mess with it a little bit in the coming days, so I'll edit or post here again with what I come up with. (:

Distortion 12-03-2015 07:11 PM

Merci Beacoup!
 
Thanks ^.^

tahbikat 12-06-2015 07:57 PM

Soooo I noticed a major problem.


I'm not sure but I *think* if a user visits the explore page too soon, before the 24 hours passes completely, it counts the explore times towards the new day. So essentially even though the page says "It seems you have explored too much today" it counts that visit as an exploration time, which adds all the exploration times to the new day, meaning users can't explore like... ever again unless they actually wait 24 hrs to the minute.

Or something like that is going wrong. I'm not a coder so I really don't know where/what the flaw is. If I knew how to just reset the exploretimes database column every 24hrs that'd be golden, but I feel like that would be a cron job or some complicated php script and that's way out of my capabilities. :/

I think I'll just add a crazy explore limit like 99999 (if possible) and set rare drop rates much much higher to remedy this in the meantime, until I can figure something out. Otherwise I really love this mod.

Abronsyth 12-07-2015 02:47 PM

Excellent tutorial! Had to tweak some things, but very nice!

Distortion 12-19-2015 01:02 PM

Explore System Modifications
 
Add explore page text
place the code below before
PHP Code:

if ($mysidia->user->exploretimes <= 100) { 

:
PHP Code:

$document->add(new Comment("Page Text<br>")); 

Adding Adopt Images
PHP Code:

if($random >= 41 && $random <= 60){
$species "AdoptName";
$newadopt = new StockAdopt($species);
$newadopt->append($mysidia->user->username);
$adoptIMG $mysidia->db->select("adoptables", array("eggimage"), "id = 'PlaceAdoptIDHere'")->fetchColumn();
$document->add(new Comment("<center><img src='$adoptIMG' alt='$species IMG' /><center><br> Oh look! You found a $species! It's pretty common."FALSE));
            } 

Adding item images
PHP Code:

if($random >= 81 && $random <= 90){
$item "ItemName";
$qty 1;
$newitem = new StockItem($item);
$newitem->append($qty$mysidia->user->username);  
$itemIMG $mysidia->db->select("items", array("imageurl"), "id = 'PlaceItemIDHere'")->fetchColumn();
$document->add(new Comment("<center><img src='$itemIMG' alt='$item IMG' /></center><br>Oh look! You found a <b>$item</b>!"FALSE));
            } 

Explore Again Link
Find this line
PHP Code:

else{
            
$document->add(new Comment(" Oops! Something went wrong."FALSE));
            } 

replace with:
PHP Code:

else{
            
$document->add(new Comment(" <a href='/explorearea1'>Explore?</a>"FALSE));
            } 

find:
PHP Code:

if($random >= 91 && $random <= 99){
$document->add(new Comment("You didn't find anything. Better luck next time."FALSE));
            } 

replace with:
PHP Code:

if($random >= 91 && $random <= 99){
$document->add(new Comment("You didn't find anything. Better luck next time. <a href='/explorearea1'>Explore?</a>"FALSE));
            } 

Random Item Quantity
Find this:
PHP Code:

$qty 4

Replace:
PHP Code:

$qty rand(1,5); 


Abronsyth 12-20-2015 10:44 AM

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); 


Kyttias 12-20-2015 12:35 PM

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

tahbikat 12-20-2015 02:12 PM

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));
        }
    }

}
?>


Kyttias 12-20-2015 02:37 PM

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?

tahbikat 12-20-2015 03:11 PM

Hahaha now that would be a little funny. :x

Abronsyth 12-20-2015 04:26 PM

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?

Kyttias 12-20-2015 04:40 PM

Probably, so long as lastday is being stored with that info. ^^

Abronsyth 12-20-2015 10:42 PM

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?

tahbikat 12-23-2015 07:14 PM

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.

NobodysHero 03-30-2016 07:15 PM

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));

            }
        

    }

}
?>


LUC1G07CH1 04-03-2016 08:53 AM

That's exact the mod i has looking! Thank you!

LUC1G07CH1 04-03-2016 10:17 AM

The explore homepage is all blank,what i need to do?

tahbikat 04-03-2016 10:53 AM

Does the "Choose where you want to explore?" text come up?

LUC1G07CH1 04-03-2016 06:19 PM

Checked and yes.

Ruri Lesavka 06-06-2016 02:04 AM

Do you think there can be a away to use stats with the explore system? Instead of having a certain item in the inventory, it will look for a certain stat on your fav pet.

I have stats like str, int, agi, def. To explore a area that fav pet str should be over a certain number for the user to continue.

Abronsyth 06-08-2016 07:50 AM

That is very possible! I don't have the files I need with me on this computer, but once I get on my laptop I'll be able to work on this. I do need to check out how to select a user's fave pet, specifically, so it might take some time. In the mean time, you should have a look at this thread :)
http://mysidiaadoptables.com/forum/s...ead.php?t=5116

RestlessThoughts 06-08-2016 05:00 PM

I have the files on hand :)
Here's the code you need to select the fav pet:
PHP Code:

$mysidia->user->getprofile();
if ((int)
$profile->getFavpetID() == 0) {
      
$document->addLangVar('No fav pet set.');
      return;
}
$favpet = new OwnedAdoptable($profile->getFavpetID());

// Now you can select the stats of the pet.

if ($favpet->str 10){
      
$document->addLangVar('Your pet isn\'t strong enough to travel here.');
      return;
}

// Explore code here. 


Ruri Lesavka 06-14-2016 01:26 AM

Quote:

Originally Posted by Abronsyth (Post 34615)
x

Thanks for trying to help. I'll probably use it to check for particular pet~

Quote:

Originally Posted by RestlessThoughts (Post 34616)
x

Thank you :D
When I first just put it in it gave a "Fatal error: Call to a member function getFavpetID() on null" error. I figured out that I needed "$profile = $mysidia->user->getprofile();" in there too. Now it works <3

Storyteller 08-09-2016 09:00 PM

I tried this and got:

Fatal error: Class 'AppController' not found in [...]/wubbiepets/explorearea1.php on line 6

What am I doing wrong?

NobodysHero 10-01-2016 04:29 PM

What's on line 6?

Corsair 11-30-2016 04:42 AM

I keep getting this error when I try to make a explore page. The main explore page works but not any of the others. I then had to just move the items and pets to the main page because it would not work.

Quote:

Fatal error: Class 'AppController' not found in /home/monstari/public_html/explorearea1view.php on line 3

Dinocanid 11-30-2016 09:26 AM

What does your code look like on line 3?

SilverDragonTears 01-26-2017 08:05 PM

Error
PHP Code:

 Fatal error: Class 'View' not found in /home/silvatal/public_html/view/explorearea1view.php on line 3 


Dinocanid 01-26-2017 08:11 PM

In your URL bar, do you go to explorearea1view.php? If so, get rid of the .php at the end since I get the same error when I do that. So instead of YOURSITE.com/explorearea1.php, it should be YOURSITE.com/explorearea1.

SilverDragonTears 01-27-2017 11:35 AM

That just took me back to the index page :(

NobodysHero 02-14-2017 12:39 PM

Is there a way to make it so users can click to get the item or pet that shows up, instead of them automatically getting them? This way they're not getting slammed with a pet they may not want or item that might not need.

NobodysHero 02-14-2017 12:55 PM

Silver, what did you call your explore pages? Did you call them explorearea1, explorearea2, etc?

Abronsyth 02-15-2017 09:56 AM

NoBody's Hero, you'd need to create a hidden form and set the pet/item image as the button, and then use an if input statement to run the append action upon clicking. Then you could just add a refresh line so that it brings them back to the explore page after a few moments. Kyttias has a script similar like this with her explore script, but you could certainly apply the same concept to this explore script; http://mysidiaadoptables.com/forum/s...ead.php?t=4955

I hope that helps :D

NobodysHero 02-20-2017 11:48 AM

Thanks, Abronsyth! <3 I posted there.:happycbig: You guys are great.

Dinocanid 03-22-2017 09:16 PM

I've run into a problem where clicking "explore?" makes you take 2 steps at a time. Or when the steps reset for the day, you might start out with 2 or 4 steps upon clicking the page. This is what I have (not including the css):
PHP Code:

class Explorearea1View extends View{
    
    public function 
index(){
        
$mysidia Registry::get("mysidia");
        
$document $this->document;
            
$document->setTitle("Forest Path");  
        
$today date("d"); //Day of the month
        
$profile $mysidia->user->getprofile();
                
$favpet = new OwnedAdoptable($profile->getFavpetID());
                
$name $favpet->getName();
                
$coatiChance rand(1,100);
                
$boarChance rand(1,100);
                
$stepstaken $mysidia->user->exploretimes;
        
// 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 <= 40 || $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;  
                
//$ExploreTimesFix = $mysidia->user->exploretimes - 1;
                 
                
$mysidia->db->update("users", array("exploretimes" => ($updatedExploreTimes)), "username = '{$mysidia->user->username}'");
                
//$mysidia->db->update("users", array("exploretimes" => ($ExploreTimesFix)), "username = '{$mysidia->user->username}'");

          
$document->add(new Comment("<div class = 'scene'><img src='http://orig08.deviantart.net/ccf7/f/2017/038/9/8/forestexplore_by_hoafan-day972y.png' style='width:50%;height:50%;'></div>"));
          
$document->add(new Comment("<b>Steps: {$stepstaken} / 40</b>"));
          
          
// This part gives a coati swirl to the user!
          
if($mysidia->input->post("coati")){
        if(
$coatiChance >= 70) {
        
$species "Coati Swirl";
        
$document->add(new Comment("The Coati doesn't want to follow, but it gives {$name} an egg instead! It can be found in your pantry"));
        
$newadopt = new StockAdopt($species);
    
$newadopt->append($mysidia->user->username);}
    elseif(
$coatiChance 70) {$document->add(new Comment("The coati quickly scurries off; startled by {$name}. Better luck next time!"));}
        }
        
        
// This part gives a boarBQ to the user!
          
if($mysidia->input->post("boarBQ")){
        if(
$boarChance >= 80) {
        
$species "BoarBQ";
        
$document->add(new Comment("{$name} somehow finds a way to calm its temper, and it gives them an egg! It can be found in your pantry"));
        
$newadopt = new StockAdopt($species);
    
$newadopt->append($mysidia->user->username);
    }
    elseif(
$boarChance 80) {$document->add(new Comment("{$name} runs for their life as the boar charges with sharp tusks!"));}
        }
        
          
//This is where exploration starts!
        
if ($mysidia->user->exploretimes <= 40) {  
            
$random rand(1,100);

            if(
$random && $random 20){
                
$species "Coati Swirl";
                
                
                
//adopt's image!
                
$document->add(new Comment("<div class = 'adopt'><img src='http://orig07.deviantart.net/b589/f/2017/070/8/c/csadult_by_hoafan-db1zf6y.png'></div>"));
                
$document->add(new Comment("Woah there! Is that a {$species}? Maybe {$name} can convince it to follow?"));
                
$CoatiForm = new FormBuilder("coatiform""""post");
        
$CoatiForm->buildButton("Try your luck""coati""submit");
                
$document->add($CoatiForm);
            }
            if(
$random >= 21 && $random <= 30){
                 
                
                
$document->add(new Comment("{$name} finds absolutely nothing.")); 
            }

            if(
$random >= 41 && $random <= 60){
            
                
$document->add(new Comment("{$name} accidentally tripped over a rock, but they seem okay."));
            }
            if(
$random >= 61 && $random <= 70){
                
$species "Boar BQ";
                
$document->add(new Comment("<div class = 'adopt'><img src='http://orig02.deviantart.net/4e8b/f/2017/077/c/e/bbqadult_by_hoafan-db2qlpt.png'></div>"));
                
$document->add(new Comment("Look out, it's a {$species}! It doesn't look too friendly..."));
                
$BoarForm = new FormBuilder("boarform""""post");
        
$BoarForm->buildButton("Try your luck""boarBQ""submit");
                
$document->add($BoarForm);
                
            }
            if(
$random >= 71 && $random <= 75){
                
$species "Spaniel Flan";
                
//$newadopt = new StockAdopt($species);
                //$newadopt->append($mysidia->user->username);
                
                
$document->add(new Comment("{$name} can hear birds chirping."));
            }
            if(
$random >= 91 && $random <= 99){
            
$amount rand(1,5);
                
$mysidia->user->changecash($amount);
                
$document->add(new Comment("Oh look! {$name} found $ {$amount}!"));
                    }  
            if(
$random == 100){
                
$species "Spaniel Flan";
                
//$newadopt = new StockAdopt($species);
                //$newadopt->append($mysidia->user->username);
                
                
$document->add(new Comment("{$name} sees something dart past in the bushes. It was too fast to recognize."));
            }
            else{
            
                        
$document->add(new Comment("<a href='/explorearea1'>Explore?</a>"FALSE));
            }  
        }
        else{
        
$document->add(new Comment("It seems that {$name} explored too much today, why don't you let them rest?"FALSE));
        }   

    }
    }



"ExploreTimesFix" was a remedy I tried to use to counter the 2-steps thing by just removing 1 step, but it just ended up subtracting 2 steps instead of adding 2, which fixed nothing if not make it worse than it was, so I commented it out.

There's also the occasional moment where no dialogue will appear besides the "explore?" link; and running out of steps will show the user a blank page. (Not a white page, but just a blank page with no words or pictures)


All times are GMT -5. The time now is 11:14 AM.

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