Multiple Characters on One Account [Solved - for now]
- RogueTomboy
- Posts: 61
- Joined: Sun May 22, 2011 3:42 pm
Multiple Characters on One Account [Solved - for now]
I was wondering if it would be at all possible to make it so that when a user registers he/she can make 1 character. Then in Settings or something he/she can have another character slot and create a new character.
Whenever they log in to their account instead of going straight into the news section of the game it will take them to a splash screen for them to decide which of the 2 characters they wish to play. Once chosen they are logged in as that character and can continue on that characters quest line, see its gold, inventory, bank, etc.
I'm sorry if I didn't explain it well but that is what I was wondering could be done - if so - could someone point me in the right direction?
Whenever they log in to their account instead of going straight into the news section of the game it will take them to a splash screen for them to decide which of the 2 characters they wish to play. Once chosen they are logged in as that character and can continue on that characters quest line, see its gold, inventory, bank, etc.
I'm sorry if I didn't explain it well but that is what I was wondering could be done - if so - could someone point me in the right direction?
Last edited by RogueTomboy on Fri Jul 22, 2011 10:58 am, edited 3 times in total.
Need art? Commissions are always open!
http://www.ladytankstudios.com
Currently addicted to:

Collect & Explore for pets
http://www.ladytankstudios.com
Currently addicted to:

Collect & Explore for pets
- Jackolantern
- Posts: 10891
- Joined: Wed Jul 01, 2009 11:00 pm
Re: Multiple Characters on One Account
Sure! Its not that hard. In your players database table, you would need to add another field called "Account", which would have the account name along with the player name. Then, when players log in with their account name, you sign them in with a session variable of their account name. Once they get past that, you can present them with a form to pick one of their characters or create a new one. Once they pick a character you save the character name into session as well.
If you are not sure how to search the database by the account name and pull up and display all of the player entries for them to select, here is some code I used before to loop through all the results and display them in a table:
The $row[13] and so on correspond to the column order in the database, so if you want to show the first column, you would use $row[0], fourth column would be $row[3], etc.
If you are not sure how to search the database by the account name and pull up and display all of the player entries for them to select, here is some code I used before to loop through all the results and display them in a table:
Code: Select all
echo "Choose a monster by clicking its name, or create a new monster: <br />";
//check to see what monsters the logged in player has from the 'playermonster' table
$sql = "SELECT * FROM playermonster WHERE playerid = '$playerid'";
if ($result = mysqli_query($db, $sql)) {
//fetch array and set up table
?>
<table border="3" cellpadding="3" cellspacing="0">
<tr>
<th align="center">Name</th>
<th align="center">Level</th>
<th align="center">Monster Type</th>
<th align="center">Monster Species</th>
<th align="center">Max Health</th>
<th align="center">Attack</th>
<th align="center">Defense</th>
<th align="center">Speed</th>
<th align="center">Mind</th>
<th align="center">Will</th>
</tr>
<?php
while ($row = mysqli_fetch_row($result)) {
//create the table to choose a monster
?>
<tr>
<td align="center"><?php echo("<a href='monsterselected.php?mid=$row[0]'>$row[2]</a>") ?> </td>
<td align="center"><?php echo($row[13]) ?> </td>
<td align="center"><?php echo($row[3]) ?> </td>
<td align="center"><?php echo($row[4]) ?> </td>
<td align="center"><?php echo($row[6]) ?> </td>
<td align="center"><?php echo($row[8]) ?> </td>
<td align="center"><?php echo($row[9]) ?> </td>
<td align="center"><?php echo($row[10]) ?> </td>
<td align="center"><?php echo($row[11]) ?> </td>
<td align="center"><?php echo($row[12]) ?> </td>
</tr>
<?php //go back into PHP for rest of script
}
?>
</table>The indelible lord of tl;dr
- RogueTomboy
- Posts: 61
- Joined: Sun May 22, 2011 3:42 pm
Re: Multiple Characters on One Account
Thanks Jack! I will have a look at this and play with it some when I get off of work! (I would have responded yesterday but I was out watching a movie).
Need art? Commissions are always open!
http://www.ladytankstudios.com
Currently addicted to:

Collect & Explore for pets
http://www.ladytankstudios.com
Currently addicted to:

Collect & Explore for pets
- RogueTomboy
- Posts: 61
- Joined: Sun May 22, 2011 3:42 pm
Re: Multiple Characters on One Account
Okay I updated my DB with account and I went into my pages to update the new information. I can register with an account name but when I go to log in it says that it's the wrong name/password.
I'm not sure what I'm doing wrong...
Here are my codes:
LOGIN.php
AUTHENTICATE.php
REGISTER2.php (well - part of it anyway)
I'm not sure what I'm doing wrong...
Here are my codes:
LOGIN.php
Code: Select all
<font face="Arial">
<link href="splashpage.css" rel="stylesheet" type="text/css" />
<center><table width="960">
<tr><td colspan="3">
<img src='images/SPLASHPAGE2.png'>
</td>
</tr>
<div id="login">
<tr><td><form method="POST" action="authenticate.php">
<font color="#ffffff">Account Name <input type="text" name="account" size="21"></font><br><br><br>
<font color="#ffffff">Password <input type="password" name="password" size="21" mask="x"></font><br><br>
<font color="#ffffff">Want to add a FORGET PASSWORD system thing here</font>
<br><br><br><br><input type="image" src="images/login.png" border="0" value="submit" alt="submit" name="submit"></form>
</div>
</td>
<td>
<div id="screens">
this is where all the screenshots will be held. I hope to fix this text and 6 screenshots here.
</div>
</td>
<td>
<form method="POST" action="register2.php">
<input type="image" src="images/register.png" border="0" value="register" alt="register" a href="register2.php"></a></form>
</div>
</td>
</tr>
</table>
</center>
</font>Code: Select all
<?php
include_once 'connect.php';
session_start();
?>
<link href="splashpage3.css" rel="stylesheet" type="text/css" />
<center><table width="960">
<tr><td>
<img src='images/SPLASHPAGE2.png'>
</td></tr>
<tr><td>
<div id='blurb' align='center'>
<?php
if(isset($_POST['submit_x']))
{
$account=$_POST['account'];
$password=$_POST['password'];
$account=strip_tags($account);
$password=strip_tags($password);
$password=md5($password);
$query = "select account,password from players where name='$account' and password='$password' ";
$result = mysql_query($query) or die("Could not query players");
$result2 = mysql_fetch_array($result);
if ($result2)
{
$_SESSION['account']=$account;
echo "<big>Logged in successfully!<br><br><br>";
echo "<a href='index.php'><img src=/images/enter.png></a>";
}
else
{
echo "<big>Wrong account name or password.<A href='login.php'>Try Again</a></big>";
}
}
?>
</div>
</td></tr>
</table>
Code: Select all
<div id='regstuff'>
<table width="960" border='0'>
<tr valign="top">
<tr>
<td colspan="2"><font color='white' font face='arial'>Once you have picked your race make sure you pick your gendter!<br><br></td></tr>
<tr>
<td colspan="2"><font color='white' font face='arial'><input type ="radio" name="gender" value="0" checked="checked" /> Male <input type ="radio" name="gender" value="1" /> Female</center><br><br><br></td></tr>
<tr>
<td colspan="2"><font color='white' font face='arial'>Type Account Name Here: <input type="text" name="account" size="21"><br>
<font color='white' font face='arial'>Type Username Here: <input type="text" name="player" size="21"><br>
<font color='white' font face='arial'>Type Password Here: <input type="text" name="password" size "15"><br>
<font color='white' font face='arial'>ReType Password Again: <input type="text" name="pass2" size "15"><br>
<font color='white' font face='arial'>Type Email Address: <input type="text" name="email" size "60"><br>
<input type="submit" value="Submit" />
</form></td></tr>
</div>
</table>
</font>Need art? Commissions are always open!
http://www.ladytankstudios.com
Currently addicted to:

Collect & Explore for pets
http://www.ladytankstudios.com
Currently addicted to:

Collect & Explore for pets
Re: Multiple Characters on One Account
Weird, that authenticate seems alright...? Are you sure your putting in the password right? When testing with winamp, I just use the same password as the player name, since they are all offline dummy entires anyway.
Anyone else got ideas?
Anyone else got ideas?
- RogueTomboy
- Posts: 61
- Joined: Sun May 22, 2011 3:42 pm
Re: Multiple Characters on One Account
Thanks for looking Callan.
I just tried putting in my username and pw and it worked as compared to putting in ACCOUNT name and password. Is it supposed to do that? I thought once an account was made then I'd have to login with my account name and not my username.
Did I just totally mess up the codes?
Everything that says account was once player...
And looking around my other pages too...I suppose I need to change every 'player' call/post to account?
I am slightly confused by doing what I need to do in making the account/character session variable stuff :S
I just tried putting in my username and pw and it worked as compared to putting in ACCOUNT name and password. Is it supposed to do that? I thought once an account was made then I'd have to login with my account name and not my username.
Did I just totally mess up the codes?
Everything that says account was once player...
And looking around my other pages too...I suppose I need to change every 'player' call/post to account?
I am slightly confused by doing what I need to do in making the account/character session variable stuff :S
Need art? Commissions are always open!
http://www.ladytankstudios.com
Currently addicted to:

Collect & Explore for pets
http://www.ladytankstudios.com
Currently addicted to:

Collect & Explore for pets
Re: Multiple Characters on One Account
My solution was pretty simple to implement. Once a player registers it makes the master account. When you log in the first time it checks to see if you have a character, if not then you are asked to create your first character which is then added to the characters table using your account id. Each log in after the first takes you to the character selection screen. You can then select your character or make a new one.
This was actually a byproduct of me working with Facebook to do what Zynga does with having a master accounts for multiple games.
This was actually a byproduct of me working with Facebook to do what Zynga does with having a master accounts for multiple games.
- Jackolantern
- Posts: 10891
- Joined: Wed Jul 01, 2009 11:00 pm
Re: Multiple Characters on One Account
That is pretty much how my monster selection worked in my ill-fated monster fighting game. If you want, Rogue, I can post the full set of scripts for the monster selection, which (if I remember right) includes the script to pull up what monsters the character has, delete monsters, create new monsters, and select a monster to start the game with.
The indelible lord of tl;dr
- RogueTomboy
- Posts: 61
- Joined: Sun May 22, 2011 3:42 pm
Re: Multiple Characters on One Account
Sure Jack, that would be great - thank you 
Need art? Commissions are always open!
http://www.ladytankstudios.com
Currently addicted to:

Collect & Explore for pets
http://www.ladytankstudios.com
Currently addicted to:

Collect & Explore for pets
- Jackolantern
- Posts: 10891
- Joined: Wed Jul 01, 2009 11:00 pm
Re: Multiple Characters on One Account
Sent you a PM back
If anyone else is interested in them, let me know, and I will just paste in the pertinent scripts here.
The indelible lord of tl;dr