![]() |
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:
|
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:
|
...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? |
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:
|
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?
|
Hahaha now that would be a little funny. :x
|
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? |
Probably, so long as lastday is being stored with that info. ^^
|
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?
|
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. |
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:
|
That's exact the mod i has looking! Thank you!
|
The explore homepage is all blank,what i need to do?
|
Does the "Choose where you want to explore?" text come up?
|
Checked and yes.
|
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. |
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 |
I have the files on hand :)
Here's the code you need to select the fav pet: PHP Code:
|
Quote:
Quote:
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 |
I tried this and got:
Fatal error: Class 'AppController' not found in [...]/wubbiepets/explorearea1.php on line 6 What am I doing wrong? |
What's on line 6?
|
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:
|
What does your code look like on line 3?
|
Error
PHP Code:
|
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.
|
That just took me back to the index page :(
|
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.
|
Silver, what did you call your explore pages? Did you call them explorearea1, explorearea2, etc?
|
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 |
Thanks, Abronsyth! <3 I posted there.:happycbig: You guys are great.
|
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:
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 07:46 PM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.