http://www.mediafire.com/?d3z69n66iwz7zao:
Screenshots of a few imporatnt things
I am trying to give as much info as possible
code for displaying my quests:
Code: Select all
<?php
//links connect.php
include 'connect.php';
//starts a session
session_start();
?>
<!-- sets up a style sheet, that sets the text colour, and the background image -->
<style type="text/css">
<!--
body {
color: #FFFFFF;
}
body {
background-color: #000000;
background-image: url(empty_space.jpg);
}
-->
</style><center>
<!-- puts the logo on the page -->
<img src="logo.png" width="600" height="220" />
</center>
<?php
//checks if there is a session, and makes sure the player is logged in
if (isset($_SESSION['player']))
{
//creates the variable player with the contents being th ecurrently loaded session
$player=$_SESSION['player'];
//gets all the player info and loads it into an array
$playerinfo="SELECT * from gamers where playername='$player'";
$playerinfo2=mysql_query($playerinfo) or die("Could not get user stats");
$playerinfo3=mysql_fetch_array($playerinfo2);
$bypass=0;
}
//if there isnt a session it prints that the player isn't logged in, and provides a link to log in.
else
{
print "Sorry, not logged in please <A href='login.php'>Login</a><br>";
exit;
}
?>
</div>
<?php
$bypass = 0;
$newquest = 0;
$qlevel="SELECT * from playerquests WHERE pname='$playerinfo3[playername]'";
$qlevel2=mysql_query($qlevel) or die(mysql_error() . " Line 34");
if (mysql_num_rows($qlevel2))
{
//creates 2 mysql queries.
//$gettingQuestsToDo1 selects all from the table questgivers where the results are not equal to the questgiver and
//level recorded in the table player quests.
//not sure about gettingQuestsToDo2
$gettingQuestsToDo1 = "select * from questgivers where !(";
$gettingQuestsToDo2 = " or (";
for ($count = 0; $qlevelData = mysql_fetch_assoc($qlevel2); ++$count)
{
$gettingQuestsToDo1 .= "questgiver = '".$qlevelData['questgiver']."' and level <= ".$qlevelData['level']." and ";
$qlevelData['level'] += 1;
$gettingQuestsToDo2 .= "level = ".$qlevelData['level']." and questgiver = '".$qlevelData['questgiver']."' or ";
}
$gettingQuestsToDo1 .= "1)";
$gettingQuestsToDo2 .= "0)";
//$gettingQuestsToDo combines both $gettingQuestsToDo1 and $gettingQuestsToDo2, and orders them
//by the questgiver's name, and the level of the quest
$gettingQuestsToDo = $gettingQuestsToDo1.$gettingQuestsToDo2." ORDER BY questgiver, level";
} else
{
//else if there is nothing in playerquests $gettingQuestsToDO selects all from the questgivers table
$gettingQuestsToDo = "select * from questgivers order by questgiver, level";
}
//die ($gettingQuestsToDo);
//queries the two SQL queries
$questsToDo = mysql_query($gettingQuestsToDo) or die (mysql_error());
//if there are no rows in $questsToDo
if (!mysql_num_rows($questsToDo)) // This is not completely accurate yet.
{
echo "There are no available quests at this time.<br><br>";
echo "<a href='index.php'>Home</a>";
}
else
{
print "<center><h3>Quests</h3></center>";
print "<center>";
print "<table border='0' width='70%' cellspacing='20'>";
print "<tr><td width='25%' valign='top'>";
print "</td>";
print "<td valign='top' width='75%'>";
print "<table border='2' bordercolor='white' bgcolor='black' >";
print "<tr><td>Name<font color='black'>_________________</td><td>Experience<font color='black'>_</td><td>Credits<font color='black'>_</td><td>Quest Giver<font color='black'>_</td><td>Quest Level<font color='black'>_</td></tr>";
$lastquestgiver ="";
while ($questRow = mysql_fetch_assoc($questsToDo))
{
if ($questRow['questgiver'] != $lastquestgiver)
{
$SQL="SELECT * from currentquests where name='$questRow[name]' AND pname='$playerinfo3[playername]'";
$SQL2=mysql_query($SQL) or die(mysql_error() . " Line 122");
$SQL3=mysql_fetch_array($SQL2);
print "<tr><td>$questRow[name]</td><td>$questRow[exper]</td><td>$questRow[credits]</td><td>$questRow[questgiver]</td><td>$questRow[level]</td>";
if (!$SQL3['name'])
{
print "<td><a href='questsaccepted.php?name=$questRow[name]'>Accept</a></td</tr>";
}
else
{
print "<td><a href='completequest.php?name=$questRow[name]'>Complete</a></td</tr>";
}
$lastquestgiver = $questRow['questgiver'];
}
}
echo "</table>";
echo "</td></tr>";
echo "</table>";
echo "<br><br><a href='index.php'>Home</a>";;
}Code: Select all
<?php
//links connect.php
include 'connect.php';
//starts a session
session_start();
?>
<!-- sets up a style sheet, that sets the text colour, and the background image -->
<style type="text/css">
<!--
body {
color: #FFFFFF;
}
body {
background-color: #000000;
background-image: url(empty_space.jpg);
}
-->
</style><center>
<!-- puts the logo on the page -->
<img src="logo.png" width="600" height="220" />
</center>
<?php
//checks if there is a session, and makes sure the player is logged in
if (isset($_SESSION['player']))
{
//creates the variable player with the contents being th ecurrently loaded session
$player=$_SESSION['player'];
//gets all the player info and loads it into an array
$playerinfo="SELECT * from gamers where playername='$player'";
$playerinfo2=mysql_query($playerinfo) or die("Could not get user stats");
$playerinfo3=mysql_fetch_array($playerinfo2);
$bypass=0;
}
//if there isnt a session it prints that the player isn't logged in, and provides a link to log in.
else
{
print "Sorry, not logged in please <A href='login.php'>Login</a><br>";
exit;
}
?>
</div>
<?php
$questname=$_GET['name'];
//gets the level of the quest the character is up to
$qlevel="SELECT * from playerquests WHERE pname='$playerinfo3[playername]'";
$qlevel2=mysql_query($qlevel) or die(mysql_error() . " Line 72");
$qlevel3=mysql_fetch_array($qlevel2);
//if the player hasn't done any quests then the quest level is 1
if (!$qlevel3['level'])
{
$qlevel3['level'] = 1;
}
$questinfo="SELECT * from questgivers where name='$questname' AND level='$qlevel3[level]'";
$questinfo2=mysql_query($questinfo) or die(mysql_error() . " Line 38");
$questinfo3=mysql_fetch_array($questinfo2);
//inserts the quest giver, player's name, quest description, the quest name, and the required item type into the
//current quests table
$curquest="INSERT into currentquests(questgiver,pname,description,name,reqitemtype) VALUES ('$questinfo3[questgiver]','$playerinfo3[playername]','$questinfo3[description]','$questname','$questinfo3[reqitemtype]')";
mysql_query($curquest) or die(mysql_error() . " Line 89");
echo "Quest added to your quest log!<br>";
echo "<a href='quests2.php'>Back</a>";Code: Select all
<?php
//links connect.php
include 'connect.php';
//starts a session
session_start();
?>
<!-- sets up a style sheet, that sets the text colour, and the background image -->
<style type="text/css">
<!--
body {
color: #FFFFFF;
}
body {
background-color: #000000;
background-image: url(empty_space.jpg);
}
-->
</style><center>
<!-- puts the logo on the page -->
<img src="logo.png" width="600" height="220" />
</center>
<?php
//checks if there is a session, and makes sure the player is logged in
if (isset($_SESSION['player']))
{
//creates the variable player with the contents being th ecurrently loaded session
$player=$_SESSION['player'];
//gets all the player info and loads it into an array
$playerinfo="SELECT * from gamers where playername='$player'";
$playerinfo2=mysql_query($playerinfo) or die("Could not get user stats");
$playerinfo3=mysql_fetch_array($playerinfo2);
$bypass=0;
}
//if there isnt a session it prints that the player isn't logged in, and provides a link to log in.
else
{
print "Sorry, not logged in please <A href='login.php'>Login</a><br>";
exit;
}
?>
</div>
<?php
$newquest = 0;
$questname=$_GET['name'];
//gets the level of the quest the character is up to
$qlevel="SELECT level from playerquests WHERE pname='$playerinfo3[playername]'";
$qlevel2=mysql_query($qlevel) or die(mysql_error() . " Line 72");
$qlevel3=mysql_fetch_array($qlevel2);
//if the player hasn't done any quests then the quest level is 1
if (!$qlevel3['level'])
{
$qlevel3['level'] = 1;
}
$questinfo="SELECT * from questgivers where name='$questname' AND level='$qlevel3[level]'";
$questinfo2=mysql_query($questinfo) or die(mysql_error() . " Line 38");
$questinfo3=mysql_fetch_array($questinfo2);
//if the type of item required is an item then
if($questinfo3['reqitemtype'] == 'item')
{
//makes a variable called item count and sets it to 0
$itemcount = 0;
//selects everything in the inventory under the name of the item required for the quest, and the name of the player
$iteminfo="SELECT * from inventory where name='$questinfo3[reqitem]' AND pname='$playerinfo3[playername]'";
$iteminfo2=mysql_query($iteminfo) or die(mysql_error() . " Line 69");
//while the variable $iteminfo3 has any items under the name of the required item
//it increases what $itemcount equals
while ($iteminfo3=mysql_fetch_array($iteminfo2))
{
$itemcount= $itemcount + 1;
}
//if the variable $itemcount has less in it then is required for the quest then
if($itemcount < $questinfo3['reqamount'])
{echo "You do not have enough " . $questinfo3['reqitem'] . "s to complete this quest. ";}
//else if it has more than the required amount, or the the same as
else
{
//it creates a variable with the required amount in it
$iamount = $questinfo3['reqamount'];
//this says that while the variable $i has less value then the variable $item amount
//it deletes the required item out of the inventory and adds 1 to the variable $i.
//when the two variables have the same value it stops deleting items from the inventory
for($i = 0; $i < $iamount; $i=$i+1)
{
$updateinv="DELETE FROM inventory where pname='$playerinfo3[playername]' AND name='$questinfo3[reqitem]' limit 1";
mysql_query($updateinv) or die(mysql_error() . " Line 82");
}
//it prints out the required amount, and required item, then says that they have been removed from the inventory
echo $questinfo3['reqamount'] . " " . $questinfo3['reqitem'] . "s removed from inventory<br><br>";
//prints out the finishquest message that was set the the quest givers table
echo $questinfo3['finishquest'] . "<Br><br>";
//deletes the quest from current quests table
$updatecurquests="DELETE FROM currentquests where pname='$playerinfo3[playername]' AND name='$questname' AND questgiver='$questinfo3[questgiver]'";
mysql_query($updatecurquests) or die(mysql_error() . " Line 89");
//when the quest is finished it adds it to the player quests table so that the second level of that quest can be started
$SQLquests="SELECT * from playerquests WHERE pname='$playerinfo3[playername]' AND questgiver='$questinfo3[questgiver]'";
$SQLquests2=mysql_query($SQLquests) or die(mysql_error() . " Line 103");
//$SQLquests3=mysql_fetch_array($SQLquests2);
$playerquestrows=mysql_num_rows($SQLquests2);
if(!$playerquestrows)
{
$SQL="INSERT into playerquests(pname,name,level,questgiver) VALUES ('$playerinfo3[playername]','$questname','$qlevel3[level]','$questinfo3[questgiver]')";
mysql_query($SQL) or die(mysql_error() . " Line 124");
}
else
{
$updatepquests="update playerquests set level=level+1 where pname='$playerinfo3[playername]' AND questgiver='$questinfo3[questgiver]' AND level='$qlevel' Limit 1";
mysql_query($updatepquests) or die(mysql_error() . " Line 127");
}
//gives the player the reward of credits and experience specified in the quest givers table
$updateplay="Update gamers SET credits=credits+'$questinfo3[credits]',exper=exper+'$questinfo3[exper]' WHERE playername='$playerinfo3[playername]'";
mysql_query($updateplay) or die(mysql_error() . " Line 99");
//prints out how much credits and experience the player recieved
echo "<br><br>Recieved " .$questinfo3['exper'] . " experience and " . $questinfo3['credits'] . " credits.";
//if an item is given as a reward
if($questinfo3['item'] != 'none')
{
//selects all out of the item's table
$iteminfo="SELECT * from items where name='$questinfo3[item]'";
$iteminfo2=mysql_query($iteminfo) or die(mysql_error() . " Line 105");
$iteminfo3=mysql_fetch_array($iteminfo2);
//then inserts it into the player's inventory
$SQL="INSERT into inventory(pname,name,type,stats,statadd,price) VALUES ('$playerinfo3[playername]','$iteminfo3[name]','$iteminfo3[type]','$iteminfo3[stats]','$iteminfo3[statadd]','$iteminfo3[price]')";
mysql_query($SQL) or die(mysql_error() . " Line 108");
echo $questinfo3['item'] . " added to your backpack.<br>";
}
//puts up a button that allows you to finish the quest
echo "<br><form method='POST' action='quests2.php'>
<input type='submit' value='Finish' name='addw' />
</form><br><br>";
}
}
if ($questinfo3['reqitemtype'] == "none")
{
//prints out the finishquest message that was set the the quest givers table
echo $questinfo3['finishquest'] . "<Br><br>";
//deletes the quest from current quests table
$updatecurquests="DELETE FROM currentquests where pname='$playerinfo3[playername]' AND name='$questname' AND questgiver='$questinfo3[questgiver]'";
mysql_query($updatecurquests) or die(mysql_error() . " Line 89");
//when the quest is finished it adds it to the player quests table so that the second level of that quest can be started
$SQLquests="SELECT * from playerquests WHERE pname='$playerinfo3[playername]' AND questgiver='$questinfo3[questgiver]'";
$SQLquests2=mysql_query($SQLquests) or die(mysql_error() . " Line 103");
//$SQLquests3=mysql_fetch_array($SQLquests2);
$playerquestrows=mysql_num_rows($SQLquests2);
if(!$playerquestrows)
{
//$SQLquests3=mysql_fetch_array($SQLquests2);
$SQL="INSERT into playerquests(pname,name,level,questgiver) VALUES ('$playerinfo3[playername]','$questname','$qlevel3[level]','$questinfo3[questgiver]')";
mysql_query($SQL) or die(mysql_error() . " Line 124");
// die($SQL);
}
else
{
//$SQLquests3=mysql_fetch_array($SQLquests2);
$updatepquests="update playerquests set level=level+1 where pname='$playerinfo3[playername]' AND questgiver='$questinfo3[questgiver]' AND level='$qlevel3[level]' Limit 1";
die("Updating playerquests ");
mysql_query($updatepquests) or die(mysql_error() . " Line 127");
}
//gives the player the reward of credits and experience specified in the quest givers table
$updateplay="Update gamers SET credits=credits+'$questinfo3[credits]',exper=exper+'$questinfo3[exper]' WHERE playername='$playerinfo3[playername]'";
mysql_query($updateplay) or die(mysql_error() . " Line 99");
//prints out how much credits and experience the player recieved
echo "<br><br>Recieved " .$questinfo3['exper'] . " experience and " . $questinfo3['credits'] . " credits.";
//if an item is given as a reward
if($questinfo3['item'] != 'none')
{
//selects all out of the item's table
$iteminfo="SELECT * from items where name='$questinfo3[item]'";
$iteminfo2=mysql_query($iteminfo) or die(mysql_error() . " Line 105");
$iteminfo3=mysql_fetch_array($iteminfo2);
//then inserts it into the player's inventory
$SQL="INSERT into inventory(pname,name,type,stats,statadd,price) VALUES ('$playerinfo3[playername]','$iteminfo3[name]','$iteminfo3[type]','$iteminfo3[stats]','$iteminfo3[statadd]','$iteminfo3[price]')";
mysql_query($SQL) or die(mysql_error() . " Line 108");
echo $questinfo3['item'] . " added to your backpack.<br>";
}
//puts up a button that allows you to finish the quest
echo "<br><form method='POST' action='quests2.php'>
<input type='submit' value='Finish' name='addw' />
</form><br><br>";
}