![]() |
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:
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 Code:
<?php 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 Code:
<?php Code:
<?php 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){ Code:
if($random >= 81 && $random <= 90){ Code:
elseif($random >= 21 && $random <= 30){ Code:
if($random >= 91 && $random <= 99){ 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]"; Code:
} First Part: Code:
if($mysidia->user->status->premium == "yes"){ Code:
else{ 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("")); 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! |
Hey,
I've tried this. It's really good. :smile::smile::smile: |
Thanks! I'm glad you like it.
|
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. |
Is there a way to add an image to every explore encounter?
|
Quote:
So for example take this: PHP Code:
PHP Code:
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. (: |
Merci Beacoup!
Thanks ^.^
|
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. |
Excellent tutorial! Had to tweak some things, but very nice!
|
Explore System Modifications
Add explore page text
place the code below before PHP Code:
PHP Code:
PHP Code:
PHP Code:
Find this line PHP Code:
PHP Code:
PHP Code:
PHP Code:
Find this: PHP Code:
PHP Code:
|
All times are GMT -5. The time now is 12:57 AM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.