8ennett 0 Report post Posted September 11, 2010 Now first of all you will need to run through the advanced user account system by clicking here. We will be adding on to this system the next stage toward creating our very own MMORPG. You will need to download the next set of files from here. These files include the files from the previous tutorial so there is no need to append them to your current example. ##################### Part 1: Setup and configuration ##################### Once you have downloaded and extracted the archive in to your web directory run the Tables.sql text file in the root directory then delete it or move it out of the folder. Go in to the lib directory and open config.php for editing. Insert your database hostname, username, password and the database name. You will notice that there are now a few more configuration options in the config file. These are the following: $configsitecopyright - The name given credit in the pages copyright notice $configsitecss - The location of the sites main css file (stylesheet). The main style sheet is not included on the index.php pages but can easily be added through html. $configshowimage - The probability that a user will have to re-enter the image verification. If set to 100 then it will be every 1 in 100 pages visited (on average) that the user will be required to re-enter the verification image. This is to help prevent people from using automated software on their accounts. So you can now change the values of all the sites config through this file. In the next tutorial we will be making an admin panel where we can change these settings in a nice GUI instead of editing the file. ############### Part 2: Welcome Home ############### So now you have configured the site, you will need to register a new account. Once you are logged in you will now be taken to the new home.php file and will see a page similar to this: Now the contents of this opening page are all written in to home.php in the root directory, except for the middle right grid cell containing user info, this is what we call a module however I'll get to that in a little bit. I'll give you a brief description of the new things we have added to our custom functions library, new fields inserted in to our database tables and our CSS references. In the top left grid cell we have our username (later on we will be making these clickable links to a persons profile and coloured as well), our health and energy bars and the amount of money we are currently carrying. The health and energy bars are generated using a new function in our functions.php library called statbar(). This function will return an image which has been sized accordingly depending on how much health or energy the user has left. Once a user has less than 25% of either of these then the statbar turns from green to red. Also, if you hover your mouse over the stat bar it will display exactly how much health/energy you have left out of the maximum amount and also display a percentage. In the top right grid is our games logo. Simple enough. Next up we have our menu in the middle left grid. You can easily change this through home.php and has been styled using the css.css file. On the bottom grid we have our copyright notice which contains whatever name we typed in to our config.php file and also displays the current year so there is no need to update it. Now our middle right grid is our module window. A module is an easily applied addon to our site. If you look in home.php in our root directory you will see there are several conditional statements there instead of the page you can see above. These perform certain tests to determine what module should be displayed in this grid. The conditional statements test to see if the user is in prison, if they are then it will return the prison page which will prevent them from doing anything in the game until they are released from prison. It is also the same if they are in hospital, it will only display the hospital until they are released. We aren't going to be writing the modules for the prison and hospital in this tutorial but it's a good idea to have them tested for now so we don't have to go back later. Another test we perform is to check the value of the $_GET['l'] variable. This is crucial as it defines the module we are going to load (assuming they are not in prison or hopsital). It then searches in the modules directory (in the root directory) for BOTH a folder with the same name as the GET variable, then inside that directory a php file again with the same name. So let's say someone clicks on a link to http://forums.xisto.com/no_longer_exists/ It will test to see if this file "modules/bank/bank.php" exists. If it does then it will display the contents of bank.php in the middle right grid. If your php file does not have the same name as the folder it is in eg. "modules/bank/bnk.php" then the conditional statement will return false. If the statement returns false then it will default to the home page (modules/home/home.php). This ensures that even if an invalid link has been clicked or even just if the GET variable hasn't been defined, something will always be displayed. ##################### Part 3: Writing Our First Module ##################### So now you have seen how the modules are displayed and set up then we can start creating our first one which will be the default home page. This is shown above and basically just echoes our values from the $_SESSION variable. Also if you look at the reference to "Status" this is where we display the users current condition. If they are in hospital or in prison then it will display In Prison etc. in a red font. If they are banned it will display "Banned" in a red font. If they haven't been active within the past X amount of minutes (defined in config.php) then display Offline, otherwise if they have been active in the past X minutes then display a green message saying Online. Simple. As we build on our site we will also be expanding the information we are displaying on this page, and will also be including the users current avatar (once we have created the uploader later on). You will notice more new fields have been added to our userlist table. Apart from our cash on hand and cash in bank values we won't really be using any other new ones in this tutorial, but they will come in to use later on. So running through the file modules/home/home.php you can see how easy it is to incorporate a module in to the game. Next we are going to create our second module which will be a bank. First of all we add a new row to the menu in the root home.php and add a hyperlink to http://forums.xisto.com/no_longer_exists/. Next we make a new folder in the modules directory, call it bank, and put a new php file in there called bank.php. There you have it, you now have a new module called bank. Open the bank.php file for editing and you will find it is all fully commented so there is no need to run you through it. We can now deposit money from our hands in to our bank, and we can also withdraw money from our bank and put it in our pocket. Banks are a great place in MMORPG games because you can keep your money safe. Later on we will be creating a combat engine and a mugging module. These will both take a percentage of your cash on hand if the attacker/mugger are succesful against you. #######Conclusion ####### So there we have it, we now have our basis for what is starting to become a good MMORPG game. As usual all the php files are fully commented and run you through each step of the code so you don't get lost in the code. Coming up in the next tutorial we will be making our admin panel so we can edit our games config file nice and easily, and we will also be creating an advanced user profile page so our users can write their own profile signature, edit their details and upload their own avatar. Also this will include the profile page that is displayed for other users. Comments and critiscism are more than welcome. Share this post Link to post Share on other sites
8ennett 0 Report post Posted September 12, 2010 Just to add sorry, the next part of this tutorial will be ready in 2 days (I have other work to continue as well) so read through and study how the php files are structured and commented. Share this post Link to post Share on other sites
HannahI 0 Report post Posted September 13, 2010 Looks neat, you motivated me into trying to write my own! I promise not to look at the source code Share this post Link to post Share on other sites
8ennett 0 Report post Posted September 13, 2010 Actually the whole point of the tutorial is to look at the source code.Instead of running through every single line of code on these forums, I've commented each line of code in the php files instead. This way you can see the code in action and follow the comments to see how it was achieved.So yes, by all means read through the code. Learn as much as you can from it. As long as you go through it in stages like the tutorials are written then it should be easy enough for you to understand it all. Share this post Link to post Share on other sites
HannahI 0 Report post Posted September 13, 2010 Yeah, most of this was basic stuff for me, so it was really no use..... Share this post Link to post Share on other sites
8ennett 0 Report post Posted September 13, 2010 yeah, but as you should know it's not how advanced the code is but how you put it together that creates innovations Share this post Link to post Share on other sites
HannahI 0 Report post Posted September 14, 2010 I know, I know. Share this post Link to post Share on other sites
8ennett 0 Report post Posted September 14, 2010 Can I just add, can people please stop messaging me asking me to build an rpg specifically for them. I have no interest in building a text based rpg for anyone unless they intend to pay for my services. I'm writing these tutorials for the benefit of others to learn and study as is opaques vision for the Xisto forums and ks forums, however if you don't want to learn these skills for yourself and you want me to do all the work for you then you can employ me as a freelance software/web developer and/or networking technician as is my main profession.I don't mean to sound arrogant, but I'm sure many of you understand where i'm coming from. You can't expect a person to do all the hard work for you and reap the benefits. Appreciate the help other people are offering you, appreciate the fact they are trying to teach you these skills for yourself. If you have no interest in learning, expect to pay or be forced to use mediocre free trial/stripped down scripts. Share this post Link to post Share on other sites
iGuest 3 Report post Posted October 18, 2010 First tutorial was great. The link to these files appears to be down. Can you please fix so I can go through them? I've been trying to write my own text based game for a few months now, but I am just a self taught for fun programmer. Share this post Link to post Share on other sites
8ennett 0 Report post Posted December 17, 2010 Ok I have fixed the download links for example1.rar and example2.rar so they should work now, also sorry for the long delay but i've started writing the next tutorial now and should be finished either by tonight or tomorrow (it is friday after all). Bloody NVidia board in my laptop has been really annoying lately and wouldn't even power the laptop up for a few weeks. Turns out they are in the middle of a court case to reimburse everyone who has their defective boards so can't get the money back for any repairs until january at least. Check your hardware and see if it is listed at http://forums.xisto.com/no_longer_exists/, if so you can get a replacement or reimbursed for the cost of repairs. Apparently the board messes up the integrated power supple and wireless card, which is a major pain in the *** Share this post Link to post Share on other sites
8ennett 0 Report post Posted December 19, 2010 Ok I have just finished writing the next part of this tutorial so once it has been approved it will be available to all. Sorry for the long delay.8ennett's Text-based Mmorpg: Part 3 Share this post Link to post Share on other sites
suzma 0 Report post Posted July 28, 2011 Download dont work upload again? Share this post Link to post Share on other sites
Frazzman 0 Report post Posted August 11, 2011 Thanks alot, now going throught this one, very helpful full of comments and things to improve a very nice skeleton tutorial keep it up bro! Share this post Link to post Share on other sites