Jump to content
xisto Community
8ennett

8ennett's Text-based Mmorpg: Part 3

Recommended Posts

Now before we begin this tutorial please ensure you have run through parts 1 and 2 and made sure you understand everything that has been said. Feel free to comment on each tutorial with any questions and I will help you out as best I can.

 

Part 1: Advanced User Account System

Part 2: Welcome Home

 

Also for this tutorial you will need to download the updated files archive which contains all the new files included in this tutorial as well as all the previous files and the mysql tables document which you will need to run.

 

As with the other tutorials once you have created your database and run the tables query you will need to change the config file located in lib/config.php. I'd also like to point out to everyone that there has been no change to the table structure in this tutorial so you don't need to overwrite your current example database if you have one.

 

###############

Part 1: Administrative

###############

 

So here we are, we are going to work on our new admin panel. In this tutorial we will cover the site config editor and a special button for turning our server online and offline.

 

When we turn our server offline that means that no body can register with your site and cannot login either. Also anyone who is already logged in will be logged out, except of course admins and super admins. So what you need to do first is ensure you are registered with your site and logged in. If you haven't done so already you will also need to change your account type to "Super" so you have the master account. Change the account type in your database under the "type" column.

 

Now you are an administrator you will notice now you can see an additional item on the home menu.

 

Posted Image

 

This link will appear only if you are an admin or super admin and is a link to the admin panel. If you look in the home.php file and scroll through the code to the menu you can see how simple it is to do this, simply by checking the $_SESSION['user'] variable. As usual the lines are all commented to run you through how to do this.

 

So now we are in our new admin panel you will see two buttons, Site Config and the On/Off switch for our server. I coloured the button text using the css file, have a quick look through the page code and the css file just to see how it's done. When toggling this switch the colour of the button changes from red to green and back again.

 

Posted Image

 

If you click on the site config button then the site config settings will appear in a form below the admin panel. If you look closer at the php files you will notice the config settings editor is in a seperate php file to admin.php in the admin directory under modules. This file cannot be accessed by any other page other than our admin.php, this is because it also checks if the home include variable has been set the same as normal module pages (bank.php and home.php) so it can only be displayed if it's included in the home page, but because of the way we setup our module system they cannot access it by manipulating the $_GET variables either.

 

Posted Image

 

If you have a look through our config.php file in the admin module directory you can see how we have processed the form data using php. Obviously since we aren't writing anything to the database then we don't need to escape the characters and so on, but we still need to do a couple of checks on each post variable. We also need to output error messages in case one of these checks fails and we can identify which field we entered an incorrect value.

 

I have also added the TITLE tags to each form input. Now when you mouse over each field in the form it will bring up a description of what that setting is. Once all our form checks are complete and everything is ok then we re-write the config file in the lib folder with our new values. I also had it write all the original comments in case you want to change something manually in the config file and need help remembering what each setting does.

 

So that's pretty much it for this tutorial. In future tutorials when we create new values in our config file we will also be adding them to our admin file config editor. Also we will be creating more features in the admin panel itself once we have made them elsewhere, including an in-game content editor (items, houses, weapons, animals and so on) and also a user editor.

 

As usual any questions or comments are welcome. I won't be writing another tutorial now until the new year, although I might start one in a day or two. In the mean time keep examining the code to work out how to write your own version.

Share this post


Link to post
Share on other sites

OP: As a fellow programmer, I respect the work you've put into this, with that in mind do note that the scripts you have provided havea "few" errors within them. Having tested this myself, I can note at least 5 errors, which prevent someone from actually playing this MMO. What editor are you using to make these files? -Viral.

Share this post


Link to post
Share on other sites

Don't worry, all errors have been found and fixed in the next tutorial.If you want to pm me the errors you have found though I can check them against the six I found.Also I use dreamweaver mx, with an updated syntax library of course

Edited by 8ennett (see edit history)

Share this post


Link to post
Share on other sites

I'll probably be writing the next tutorial in a day or two (bit hungover today) but all the code has already been done so it's just a matter of writing the article. Thanks for the pm as well.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.