HOME       >>       Programming

8ennett's Text-based Mmorpg: Part 4


Before starting on this tutorial be sure to run through the first 3.


Part 1: Advanced User Account System

Part 2: Welcome Home

Part 3: Administrative



Part 4: Profiles



Download Example4.rar


In this tutorial we are going to create several things.


Contact List

Blocked Users List

Users Profile

Profile Editor

Avatar Uploader

Inbox On/Off Switch

Our contact list can be found on the updated menu under 'contacts'. This also contains the users blocked list as well at the bottom of the page.



As you can see from the above image it simply contains the name of the person on either the contact list or blocked list and also the action link which will simply say remove. You can choose to remove people off either after putting them there. Users who are on your blocked list are unable to message you, and users who are on your contacts list will be eligible to message you when you turn the 'receive messages from contacts only' option on in your profile settings. Currently there is no messaging system or profile setting for user only messages but we will be creating that in the next tutorial.


The other new item on our menu is the Contacts link. Clicking this menu link will take us to the module page modules/profile/profile.php. Now profile.php determines what users profile you are looking at through the $_GET variable USER. Eg. http://forums.xisto.com/no_longer_exists/ will display the profile for who ever has the user id 1.



As you can see on the above image it shows certain information about the user such as name, gender, account type, health stats, cash on hand, level and current status (Online, Offline, In Prison, In Hospital, Banned). Also at the bottom of the profile page is the players signature. This is an area which will only be displayed if the user has input something in to their signature. Between the signature and the players information is the control panel. Now this is obviously different depending on wether you are looking at your own profile or another players. When viewing your own profile there are four different options in our profile control panel. The first is the choice to edit your profile.



As you can see the user can change their name, email, password and signature. If you look through the code for modules/profile/edit.php you will see how we process the form data as all the lines are commented in full as usual. We also ensure that the user is actually changing certain data and only adjust the database data where necessary to save on server load. We have also added a new feature to the players signature. As well as being able to write any text they want in there, they can also insert BB Code. This is specialised code that allows users to format their text in different ways (alignment, bold, italic, underlined, size etc.) as well as being able to insert images and youtube videos. If you look through the new BBCode() function in our lib/functions.php file you can see how simple it is to add more bbcode tags of your own and the outputted html each tag results in. There is also another feature and new function in our functions file where we check to see the size of an image a user is inputting in to their signature, and if it is too wide then we rescale the image so it won't mess up the formatting of our page. Remember, all our modules can be no more than 600px wide otherwise our page starts to look distorted and mishapen. This adds another level of professionalism to your site while maintaining aesthetic integrity. The avatar on the users profile is also subject to the same rescaling except it measures both height and width and rescales to a maximum of 150px for either height or width.


Next up on the profile control panel we have the inbox on/off switch. When the inbox is turned off then the player will not receive messages from anyone but admins. We will also be creating a 'only contacts can message' button as well but that's for the next tutorial.


After the inbox on/off switch comes our avatar upload button. This loads up the page modules/profile/avatar.php. It's a very simple and effective script where the user can upload an image that is less than 100kb in size (we limit size to save server space) and can only have the extension GIF, JPG, JPEG or PNG. We have to limit the file extensions to prevent upload of malicious software and scripts.



Finally on the profile control there is the delete account button however there is still too much work to be done and unknown future table names that need to be considered so we won't be programming this yet, however there is a piece of javascript written in to the link which asks for confirmation of wether the player wants to delete their account or not. This is to prevent people from accidentally clicking it and deleting their account by mistake.


If we move on to the other player profile control panel. Start by registering a new account on your game and manually activating it through the sql database by changing the userlist-validated column to 'Yes'. Now take note of this players new id number and go back to your own account. You will notice we have added another new feature to the game and new function to the lib/functions.php file. This function is userName($id); which displays the name of the user id and also makes the name a link which when clicked takes you to the players profile. This is how we are going to display any users name in the game from now on to help make it more accessible. The link generated for the users name also has their account type in the title so when you mouse over the link you can see their account type. Anyway if you click your name in the top left corner it will take you to your profile and in the address bar should be http://forums.xisto.com/no_longer_exists/ or something similar. If you change the 'user' value to the user id of the new account you just created you can see that players profile now and the player profile control panel.



So far we only have 'Add to contacts' and 'Block user' but in the next tutorial we will be working on more things to put in here. When either of these links are clicked it then either adds the user to the contacts list or blocked list and changes the link on the page to either 'Contact' or 'Blocked' which can be viewed in the 'Contacts' link in the menu. Another feature is, if you add someone to your contacts list while they are on the blocked list then they will become unblocked, and the same the other way around. If you click block user when they are in your contacts then they are remove from your contacts.


A few other points interest are how we retrieve a users profile avatar, that is set in a custom function. Also there is the findexts() function which basically returns file extensions. We have also added level, signature, inbox, prison and hospital to our userlist table and created the contacts and blocked tables as well.


Level: This is the users experience level which increases the more experience the player gathers. Does nothing for now but will do later.

Signature: The bbcode displayed on a players profile

Inbox: The inbox on/off toggle

Prison: Timestamp of when player gets out of prison

Hospital: Timestamp of when player gets out of hospital

As usual leave any comments and questions below and I'll do my best to help. And please, can people stop asking me to make their sites for them. Just learn how to do it yourself through these tutorials.


I forgot to add sorry, you will need to change permissions for a file and a directory.First of all you will need to change the permission of 'lib/config.php' to 777, and also change the directory 'images/users' to 777 as well otherwise you won't be able to upload files or save config changes.The current version of the online script is Part 5 which I haven't finished writing the tutorial for yet, but it will be out in a couple of days. I've also changed the design of the example site which will be included in the next tutorial download.You can either register with the example site or sign in to the guest account, although for obvious reasons I haven't given it admin privelages.S/N: GuestPass: password


Uh? change to 777 ? You should not do this in a tutorial, you should teach us how to put the correct permissions, and not how lazy people (like myself) give full permission to everybody.You should probably rather test chmod 664 (as far as I remember), or at least "chmod o-w".


Yeah you're absolutely right about that, sorry. Don't chmod 777 but 664 instead. I am writing the tutorial on a private server so I forgot. 664 permits all to read, only user and group to write and none to execute.


I'm actually considering turning this in to an open-source project at the end of the tutorial. Try and gather a developing community to create a free text-based rpg system which is easy to use and feature rich and a large module database so users can create a completely customised game. That way people may turn to using this instead of being ripped off and buying something like mccodes. No doubt they overcharge for a rather limited engine. Open-source is always the best way.


I'm actually considering turning this in to an open-source project at the end of the tutorial. Try and gather a developing community to create a free text-based rpg system which is easy to use and feature rich and a large module database so users can create a completely customised game. That way people may turn to using this instead of being ripped off and buying something like mccodes. No doubt they overcharge for a rather limited engine.
Open-source is always the best way.

I vote bring back the site it was one of the most helpful things ever i would really appreciate the files and all that, thanks.


Yeah I've lost my internet connection at home and couldn't afford to get it reconnected. I'm using my mobile phone at the moment and it's costing me even more. I ran out of myCENTs and haven't had chance to get back on to Xisto and earn myself some more. I'd earned enough for the whole month before it was due however one of my other sites was due for termination and DIDN'T terminate. That left me with two invoices to pay which I couldn't afford. I have to make up enough to pay off the current debt ($1.77) and cover next months fee which is due on the 4th of next month. Looks like i'm going to be typing a lot over the next few hours so watch out Xisto cus I'm gonna stick my nose in to every single new post since my last visit lolThe project site shoudl be back up soon, but it's typical since I had just released the BETA version of the game engine right before the site went down. Beta testing kinda stopped after that lol


Xisto.com offers Free Web Hosting to its Members for their participation in this Community. We moderate all content posted here but we cannot warrant full correctness of all content. While using this site, you agree to have read and accepted our terms of use, cookie and privacy policy. Copyright 2001-2019 by Xisto Corporation. All Rights Reserved.