Sunday, February 1, 2009

Found a home

check it out here Introduction to PBBG
for the time being it will be open to all. Later I may incorporate a login (as long as the publisher is ok we'll see).

Friday, January 30, 2009

Cause of delay

Hi all, ok. there are TWO reasons for delay

small reason: blogger.com is HORRIBLE at allowing me to post source code (without having to modify the html, which is just annoying). So am currently thinking of where would be most convient to continue the tutorial.

B I G R E A S O N
I STOPED to finish the game. While a little buggy, it can be checked out here
http://www.wdxdesign.com/ls
I have a few goofy bugs Im cleaning up but its done for the most part.

That will be what the tutorial is on. Yes I know my original idea was a fantasy based, but seeing so many of them I decided to take an alternate route. Plus this program encompasses all aspects of php programming which I feel is good to bite your teeth on.

Thank you for those that have emailed me requesting the source code. It is NOT available. Sorry. Many many hours have gone into this (over 35+ pages and 10,000 lines of code so its compact and effecient). This tutorial will show you how to build it. We all know it will spread once its downloaded, so I think its best if YOU write it, then spread it around. However, you'll find that when your done, you'll have quite a bit of pride in what you created and may not be so quick to share it either. So with that in mind -

FAQ for source code:

  1. I don't want to sell it!1 (due to piracy)
  2. If you just HAVE to have it, $249.002 - so it by some "mysterious" way it ends up all over the net, there is at least some compensation.
  3. If you have the "WTF!!" attitude see FAQ #1
Bottom line, don't ask.

ABOUT THE GAME
Ok, as mentioned, I did not want to make a fantasy since there were too many already, and it seemed the top PBBG's were mobster type or money type, So I came up with this:
Takes place in the future (post apocalyptic).
  • Players move about scrounging for possible good items, from car and machinery parts, jewelry to rare clothing in good condition.
  • Sell items to various stores in the area. If not satisfied with the offer, players can haggle. If the haggle fails, players are flaged at that store. More than 5 flags and player is banned (this is set by the webmaster).
  • Players can train their stats for improvement with the money they get.
check here http://wdxdesign.com/ls/help.php for more instructions about the game.
Bear in mind at the time of this witting there are a few bugs I'm squishing, wont take long.
(NOTE: this is not the final version, just for display purposes, so anyone can log on and explore it, but as you can see its very close)



1. Some exceptions
2. When I created this, I made an installer so it would be easy for me to test it on different servers. So those of you who want to get the source, it will come with the installer. There is a disclaimer you'll have to agree to as well. Also as I update the files, you'll get the updated ones as well.

Thursday, January 1, 2009

Still Here pt2

Happy New Year!!!
Well I'm revamping all of the mmo site. For those of you who may be wondering "... why not post the completed mmo for demo'ing?" reason: I gave my Tower System to my son to give to my youngest, and of course out of excitement, tore into it and replaced it all with his "cool" software. It wasnt until after a bit writing here I reaslized the reason I was unable to find it, was because it wasnt here - sooooooo, im doing it literally ALL from scratch. So while I have many of the pages done, so as to write it here, my excitement in recreating the mmo, has taken over. But since I ALSO just realized - you dont know what this particular MMO is about and its features, well, here ya go:

  • Players start out as a drifter (nobody). as they level then can allocate skill points to one of 4 jobs: Duelist(tank/warrior), Magus(magic-user), Recluse(monk, hand-to-hand) and Ranger(ranged weapons). Putting points in these job skills will give them acess to the special abilities associated with these jobs. They can opt to put them all into one and become very powerful in THAT job or spread them out.
  • Questing - or grinding (focus on questing with a storyline)
  • Speed Chat - For those of you not familiar - see http://www.wizard101.com, http://www.toontown.com for examples. Reason? To eliminate spam and bad languge and to make sure the chat is role playing (incase many of you have forgotten, mmoR P G is ROLE PLAYING not hack and slash. So if players wanna talk smack and spam - they can use their chat program of choice - not ingame.
  • Professions, Skyping, Mining (skyping is my ingame prfession, you can do anything you want)
  • Many features found in most large scale MMO's Character sheet, Map, Inventory, Skill sheet and much more.
  • Wandering Mobs
  • Interactive NPC's
  • Much more...
The skeleton MMO that I am teaching here will allow you to expand to just about any type of game genre you imagination can take you.
So Bear with me... I'll be back shortly.

Tuesday, December 30, 2008

Still here

Most of the last few days I have been working on a main page action.php (and Im playing a ton of R.O.M. lately as well). It is one of the biggest sections of the game. It handles NPC (whether the player is talking to one or not), combat, message of the day, profession etcc). It is a huge section and I am recoding it to happen on one page.

Just some food for thought while your waiting. PHP pages can be thought of as routines in themselves. Each page you call is like a separate routine. :-)

Another thing you may be wondering is why I'm not using session variables. I will. At the time this game was designed, it was all url based. So for the ease of teaching, I thought it would be good to see how those are tossed around. Later I'll show you how to use session varibles and clean up your code.

Anyways - when i get back from finishing this part up (its huge) I'll post.
Welcome all comments.

Thursday, December 25, 2008

Login (Part III) Registration

Ok if you want people to play your game, they need to have an account, and to have an account they need to register. I'll show you a simple registration, that makes use of the table we created earlier.

registration.php




echo '
<center>
<table border="1" width="60%" cellspacing="3" cellpadding="20"><tr><td>
<table><tr><td width="30%">
<form name="register" action="reg2.php" method="POST">
<tr><td>Username:</td><td><input type="text" length="20" name="username"></td></tr>
<tr><td>Password:</td><td><input type="password" length="20" name="pw1"></td></tr>
<tr><td>Again:</td><td><input type="password" length="20" name="pw2"></td></tr>
<tr><td>email:</td><td><input type="text" length="20" name="email">
<p>
<!-- // ### USE AN INCLUDE HERE FOR A FANCY VERIFCATION
// ### CODE. ->
</td></tr>
<tr><td><input type="submit" value="Submit"></td>
<td><input type="reset" value="Reset"></td></tr>
</td>
</form>

</td></tr></table>
<td valign="top" width="70%"><font face="arial" size="2">
<div align="justify">
.:: Registration -<br>
Must have a valid email - information will be sent to this address
for verification.
</div>
</td>
</td></tr></table>
</center>
';


sorry the formatting doesnt come up nice - you can thank blogspot for that. This is the best trick i could fine to display the code, otherwise it tries to execute it.
anyways.....

This is just a simple form to get some simple information for our simple game. will look similar to below















Username:
Password:
Again:
email:






.:: Registration -

Must have a valid email - information will be sent to this address
for verification.




When a user clicks the submit button, it will send them to a reg2.php to check stuff out.

reg2.php



<?php
require("serverconfig.php");
$valid_acct=1;
$username=$_REQUEST['username'];
$userpw=$_REQUEST['pw1'];
$userchk=$_REQUEST['pw2'];
$useremail=$_REQUEST['email'];


if ($username ==""){
echo '<font color="red">Please enter your desired username</font><br>'.
'<a href="registration.php">Click Here</a> to continue...';
}// ### END DATA ENTRY CHECK

// ### CHECK TO SEE IF PASSWORDS MATCH
if ($userpw != $userchk){
echo '<font color="red">Passwords do not match<p></font><br>';
$valid_acct=0;
}

// ### CHECK TO SEE IF A VALID NAME IS ENTERED
// ### ONE THAT IS NOT USED
$result = mysql_query("SELECT * FROM accounts WHERE playername='$username'");
while($row=mysql_fetch_array($result)){
echo '<font color="red">Name is already Taken<p></font><br>';
$valid_acct=0;
}


// ### CHECK TO SEE IF EMAIL IS NOT TAKEN
$result = mysql_query("SELECT * FROM accounts WHERE email='$useremail'");
while($row=mysql_fetch_array($result)){
echo '<font color="red">Email is already in use.<p></font><br>'.
$valid_acct=0;
}

//
if ($valid_acct){
// ### CONVERT PW TO MD5
$pw3=md5($userpw);
$sql="INSERT INTO accounts (
playername,
password,
email)
VALUES (
'$username',
'$pw3',
'$useremail'
)";
if (!mysql_query($sql)){
die ('Error: '.mysql_error());
}
echo 'You are all set '.$username.' feel free to log in and play now.';
echo '<br>Good luck<P>';
echo '<a href="index.php">Click Here</a> to begin playing...';
}else{
// ### IF VALID ACCOUNT = 0 THEN HAVE THE USER GO BACK
// ### AND ENTER A VALID INFO
echo '<a href="registration.php">Click Here</a> to continue...';
}

?>


Ok there looks like a lot going on, but its actually simple (thats how programming is, you write alot to do somehting simple).
As you can see, the familiar "require" is shown as well as valid_acct (I just like it so i stick with it througout the software). Next we put everything into variables that we are going to check, username,userpw,userchk and email

Next, check to see if user forgot to put something in. If so, tell them and go back to the registration page.

Once done, make sure the password check matches. if not, back to the registration page.
Then make sure they havent picked a name that is already used, if not back to the registration page.

check the email. same thing. Getting the hang of it? Not so bad is it?

now to be safe, we turn the pw into a md5 hash. very secure for the most part because its not reversable. So if you ever see websites that "reset" your pw, or send you a temp, most likely they are using this method. You just cant get it back if you loose it.

Once that is complete, shove everything into the table - you did make your table right??
If for some reason the valid_acct is still 0, that means there was something wroing and they have to do it all over again.

Give them a link to go back and log in with their new id/pw. Note - get creative, have the program email them and verify they are who they say they are. You can also add a "gotcha". That is a random picture or alpha/numeric numbers that they have to type in to verify they are human. Buuuttttt, I dont think you have to worry about any of this right now. But have fun with it. That is how you learn.

Login (Part II) Validation NEW UPDATE!

Firs this that needs to be done (with this step) is we are going to add a table to your (wyvern) database. Call this "accounts" (original). This table is different/separate from another table we'll make called "characters". Accounts will hold information about players, while characters will hold information about the character(s) "players" create. - confused? Don't be, it'll become clear later.

Here are some of the info we're going to put into this table:
(note this will change as we go along - we only need something to get it functional)

  • id - just a counter to keep track of the acct in question.
  • playername - duh
  • password - uhm ? (jk)
  • email - for sending registration too and for recovering pw
  • admin - will this user have admin privalages (will let you program that part)
So go ahead and make a new table with those 5 items. Again, sorry, not making a Navicat tutorial, but will answer any questions anyone has. For those of you who just wanna move on with the guide you can use the following sql dump and have it done automatically, then you can look at it.

ACCOUNTS.SQL



SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for accounts
-- ----------------------------
DROP TABLE IF EXISTS `accounts`;
CREATE TABLE `accounts` (
`id` int(10) NOT NULL AUTO_INCREMENT,
`playername` char(20) DEFAULT NULL,
`password` char(100) DEFAULT NULL,
`email` char(50) DEFAULT NULL,
`admin` int(10) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=latin1;

-- ----------------------------
-- Records
-- ----------------------------



If you notice from part I, once the submit button is clicked, it will send the user to "checklogin.php" What this guys job is to simply check to see if the login is good and send them to the character selection page, where they can select one of their characters that they have made to play, alert of a bad pw/Id or both, or to a registration page.

Lets take a look at a simple "checklogin.php" file:




<?php

require("serverconfig.php");
$valid_acct=0;
$username=$_REQUEST['username'];
$userpw=$_REQUEST['password'];
$userpw= md5($userpw);
$result = mysql_query("SELECT * FROM accounts WHERE playername='$username' AND password='$userpw'");
$row=mysql_fetch_array($result) ;
if ($row){ $valid_acct=1; }

if ($valid_acct){


echo '<meta http-equiv="refresh" content="0; url=main.php?acct='.$row['id'].'">';

}else{
echo '<font color="red">Bad Login</font><br>';
echo '<a href="index.php">Click here</a> to try again';
}
?>


Pretty simple (change as you like). the first line "require" is giong to be your buddy. He actually has a brother called "include". Both work the same way with one difference. REQUIRE will stop the page if there is an error. while INCLUDE will show you the error, but attempt to make the page display. Me personally, I rather just have the train stop and see who's messin around before i continue on.

Next we set a dummy variable (boolean) valid_acct to false. then we take the information we got from the form (username and userpw) and see if there is a match. if there is, change the valid_acct to 1.

If it is a valid account, load up the getcharacter.php page (there are a couple ways to force a page, I found this one to be the best, note it may not be supported in all browsers).

If it is not valid, shows them an error, and allows them to click back to the login screen to try again.

EDIT: There has been a change - the "getcharacter.php" has been replaced with "main.php"

Wednesday, December 24, 2008

Login (Part I) - Login Screen

The login page will be your first big project. While long in explanation, it is designed to do a few simple things:

  1. Get id/pw
  2. Validate
  3. Register
  4. Reset PW
There are a BILLION differnt sites you can go to (just google "login source code php") and all will have a different method. Im hoping the method I use here will be simple, and a "little" secure (I wouldn't worry a whole lot about the security of your game yet until 1. its done and 2. its popular. But at the end of the tutorial, I will show you a few ways you can make sure that game is secure - for all you worry warts out there, this is NOT the same as securing your PC. this is just o people cannot alter the address bar and hop into someone elses character. I'll show you what I mean later. But for simple game design purposes this will do).

Open CE and make a new file called INDEX.PHP
and put this in it (don't forget the "<?php and the >")




// ### SHOW LOGIN
echo'
<center>
<h1>Wyverns Tear</h1><p>
<FORM action="checklogin.php" method="POST">
<table>
<tr>
<td>Login ID:<br>
<input type="text" length="20" name="username">
</td></tr><tr>
<td>Password:<br>
<input type="password" length="20" name="password">
</td></TR><TR>
<td>
<input type="submit" value="Login">
</td>
</tr><tr>
<td>
<a href="registration.php">Register</a>
| Forgot Info
</td>
</tr>
</table>
</form>
';


Most of this is just basic html. Notice the "echo" command. I kinda cheat and make a open quote and then shove all my html before the last '; at the bottom. So lets see what we have. Basically there are 2 input boxes. One for ID and one for PW. To get the PW box to show up as dots to hide the typing, simply use the "type" as PASSWORD. We name the id "username" and pw as "password". Pretty self explanitory. Feel free to tinker with this one. If you're really good at html this should be pretty easy.