NOT PROMISING THAT THIS WILL KEEP UP!!! Well, I'm sorta rewriting this in python. If you would like to help, let me know. Even if you don't know python, you can still help! So far, I have the character creation just about finished. One thing I need help with, is I want the program to send me an email when a player signs up, that tells me the name of the player, as well as where they heard about the program. My one problem is sending python variables in the email. Could anyone explain to me how to do this?
Here is my code so far.
#Type run() to start
def run(): start()
def start():
import time
import random
print ("Please choose a class. Your class will affect abilities your player will have, as well as your stats.")
print ("1. Knight")
print ("2. Mage")
print ("3. Elf")
answer = raw_input("Choose an option, and then press enter. ")
if(answer == "1"): type = "knight"
elif(answer == "2"): type = "mage"
elif(answer == "3"): type = "elf"
print
print
print ("You chose to be a {0}.".format(type))
time.sleep(2)
print
print
#stats
hunger = 100
health = 100
str = 0
dex = 0
wis = 0
str = random.randint(50,100)
dex = random.randint(50,100)
wis = random.randint(50,100)
print ("Rolling Stats...")
time.sleep(2)
print
print
print ("Strength: {0}".format(str))
print ("Dexterity: {0}".format(dex))
print ("Wisdom: {0}".format(wis))
print
print ("Here are your stats. They are going to stick with you though out the game. These numbers will effect how your charater performs though out the game. ")
time.sleep(2)
#name
print
print
name = raw_input("I almost forget to ask you. What is your name? ")
print
print
print ("Thank you for playing {0}.".format(name))
time.sleep(2)
#hear about us
print
print
print ("One last question. ")
answer = raw_input("Where'd you hear about us? ")
#start
print
print
print (""" You find yourself standing in the woods, with a knight mounted on a horse. """)
print (""" "So young {0}. You seem to be new to Elf Lands, so I will instruct you """.format(type))
time.sleep(5)
print (""" through the ways of playing Elf Lands." The knight says. "I'm going to""")
print ("""the town square. Here you will be able to do a number of things, including""")
time.sleep(5)
print ("""quests, and shoping. To travel, choose an exit, and type the corresponding """)
print ("""then press enter. You will then travel to that destination where your travels""")
time.sleep(5)
print ("""Will continue", he says. "Let's try it out now. I'll meet you in the west exit." """)
print ("You stand at the woods behind Elf Square.")
time.sleep(5)
print ("You notice one exit.")
print ("1. West")
answer = raw_input("Choose a number, and then press enter. ")
if answer == "1":
location = ("elfSquare")
if location == "elfSquare":
print
print
print ("You walk west towrds Elf Square. There, you meet the knight. He greets you, ")
print ("and shows you around the square.")
print ("He shows you four exits.")
print ("1. The Dark Woods")
print ("2. The Training Tent")
print ("3. The Town of Ishka")
print ("4. Seans Armory")
print("You're on your own now, young {0}. Enjoy the adventure! ".format(name))
if answer == "1":
location = ("darkWoods")
if answer == "2":
location = ("trainingTent")
if answer == "3":
location = ("Ishka")
if answer == "4":
location = ("seansArmory")Last edited by elfin8er (2012-05-07 11:31:33)

Offline
Use session variables and/or mySQL.
Here's a tutorial: http://www.w3schools.com/php/php_sessions.asp
If you just need a temporary variable, use sessions.
Basically, you start a session using session_start();, and have session variables set using $_SESSION['health']=10;.
If you need the website to permanently record the user data though, you'll need to use mySQL.
Create a new database, and a new table inside it with the details of each user's account name, health, money etc.
Then query and update the table whenever the user interacts within your RPG.
You'll need to know a certain amount of mySQL though.
Here's a beginner's tutorial: http://www.w3schools.com/php/php_mysql_intro.asp
Offline
Theoretically it should be easier to learn Python than PHP.
Offline
elfin8er wrote:
samtwheels wrote:
use python!
Would it be just as easy as PHP? Like, I'd have to get a host and everything, right? I can just use PHPMyAdmin. It's free with the webhost I'm using.
oh, you meant online. python runs on servers, but it's primarily client-side.
Offline
samtwheels wrote:
elfin8er wrote:
samtwheels wrote:
use python!
Would it be just as easy as PHP? Like, I'd have to get a host and everything, right? I can just use PHPMyAdmin. It's free with the webhost I'm using.
oh, you meant online. python runs on servers, but it's primarily client-side.
So I should stick with PHP MySQL?

Offline
elfin8er wrote:
samtwheels wrote:
elfin8er wrote:
Would it be just as easy as PHP? Like, I'd have to get a host and everything, right? I can just use PHPMyAdmin. It's free with the webhost I'm using.oh, you meant online. python runs on servers, but it's primarily client-side.
So I should stick with PHP MySQL?
Depends. If you want it to be a browser game, then definitely, stick with it. Though if you want it to be an application/program, then I would go with Python.
If you want it multiplayer, real-time strategy, Python would be a better option. If you want it to be turn-based, then PHP.
All depends on how you want the game to run. Could you give us details on what type of RPG it will be?
Offline
I want it to sort of be a browser based game, sort of like a mix between dungeons and dragons, and Choose Your Own Adventures. Here's how I'd want to layout to look.
Money: 10.00 HP: 100/100 Elfin8er
You are walking through the desert, and you see ten dollars on the ground. What would you like to do?
Pick it up
Ignore it
Now, depending on what the user picks, will depend on what happens in the game. If the user chooses to pick up the ten dollars, ten dollars will be added to the money, and the game may say something like:
You decided to pick up the ten dollars. Ten dollars has been added to your money. Now what?
Return Home
Go Swimming
Sometimes, the user will encounter enemies. It would say something like this.
You have encountered a wolf. What would you like to do?
Fight the Wolf
Run From the Wolf
Then, if the user decided to fight the wolf, the computer would decide if the user hit the wolf or not, and if so, how much HP the wolf would loose. The user would then be taken to another page saying something like:
You hit the wolf. You did 10 damage to the wolf. The wolf now has 20 HP.
and the whole thing would start over again. I think I can do that whole part. The part I'm not sure about is making a user Signup/Login page, and using the variables like that.
Last edited by elfin8er (2012-02-21 23:53:08)

Offline
Yeah, that's definitely something you want to make in PHP.
With phpMyAdmin you can create a table (like game_users) then have columns like Username, Password (make sure it's hashed), HP, XP, Money, Kills, Strength, Defense, Agility, etc.
Then you make a MySQL query to create/update/delete a row/user. Trinary's link to W3Schools is probably a good place to learn and use as a reference.
Offline
Magnie wrote:
Yeah, that's definitely something you want to make in PHP.
With phpMyAdmin you can create a table (like game_users) then have columns like Username, Password (make sure it's hashed), HP, XP, Money, Kills, Strength, Defense, Agility, etc.
Then you make a MySQL query to create/update/delete a row/user. Trinary's link to W3Schools is probably a good place to learn and use as a reference.![]()
Ok, cool, Thanks.

Offline
Hey um, just so you know, I learned C++ in under a week.
Offline
THIS IS FRYING MY BRAIN!! I've been working for hours on this, and just still can't figure it out. Could someone just collab with me for a bit, and do the PHP for/with me? I'm also getting dreamweaver, so that should make it a bit easier as well.
Last edited by elfin8er (2012-02-22 17:32:43)

Offline
I'm getting some errors with my login script. Could anyone look it over for me?
<?php
session_start();
$username = $_POST['username'];
$password = $_POST['password'];
if ($username&&$password)
{
$connect = mysql_connect("mysql6.000webhost.com","a9315431_elf","password") or die ("Failed to connect");
mysql_select_db("a9315431_elf") or die ("Failed to connect to database");
$query = mysql_query("SELECT * FROM users WHERE username='$username'");
$numrows = mysql_num_rows($query);
if($numrows !=0)
{
while ($rows = mysql_fetch_assoc($query));
{
$dbusername = $row['username'];
$dbusername = $row['password'];
}
if ($username==$dbusername&&$password==$dbpassword);
{
echo "Logged in. Click <href='http://elflands.tk/start.php'>Click Here to Start Your Adventure</a>";
$_SESSION['username']=$dbusername;
}
else
echo "Incorrect Password";
}
else
die "That username doesn't exist.";
}
else
die ("Please Enter A Username And Password");
?>Am I even on the right track here?
Last edited by elfin8er (2012-02-22 18:33:49)

Offline
You'll want to close all the else's with } and make sure to hash passwords.
Offline
This is actually a genre, and a pretty famous one at that.
It's called, oddly enough, Text-Based Gaming
And the idea looks pretty awesome.
Last edited by Earthboundjeff (2012-02-22 18:37:34)
Offline
Earthboundjeff wrote:
This is actually a genre, and a pretty famous one at that.
It's called, oddly enough, [spoiler=Text-Based Gaming]http://en.wikipedia.org/wiki/Text-based_game[/spoiler]
And the idea looks pretty awesome.
I know, but I didn't want people to get confused with choose your own adventures.

Offline