Location of the Videos
adamrain
Posts: 12 Joined: Sun Oct 11, 2009 7:51 pm
Post
by adamrain » Tue Oct 13, 2009 4:28 pm
hallsofvallhalla wrote: what does the url show when you go to attack.php. like whats after the ?
when i go to the attack.php from it showes a "No Creature selected. Go Back!"as a link
attack.php
Code: Select all
<?php
include 'connect.php';
$playerinfo="SELECT * from players where name='player1'";
$playerinfo2=mysql_query($playerinfo) or die("could not get player stats!");
$playerinfo3=mysql_fetch_array($playerinfo2);
if (isset($_GET['creature']))
{
$creature=$_GET['creature'];
$creatureinfo="SELECT * from creatures where name = '$creature'";
$creatureinfo2=mysql_query($creatureinfo) or die("could not get the creature you were fighting!");
$creatureinfo3=mysql_fetch_array($creatureinfo2);
}
else
{
echo "<a href='battle.php'>No Creature selected. Go Back!";
exit;
}
$playerhp = $playerinfo3['hpoints'];
$playerattack = $playerinfo3['attack'];
$playerdefense = $playerinfo3['defense'];
$creature = $creatureinfo3['name'];
$creaturehp = $creatureinfo3['hpoints'];
$creatureattack = $creatureinfo3['attack'];
$creaturedefense = $creatureinfo3['defense'];
///////////////////////players turn////////////////////
echo "<u> " . $playerinfo3['name'] . "'s Attack</u><br>";
$playerattack = rand(1,20) + $playerattack;
$creaturedefense = rand(1,20) + $creaturedefense;
echo $playerinfo3['name'] . "'s Attack roll is " . $playerattack . "<br>";
echo $creature . "'s defense roll is " . $creaturedefense. "<br>";
if ($playerattack > $creaturedefense)
{
echo $playerinfo3['name'] . " hits! <br>";
$playerdamage = rand(1,6);
$newcreaturehp = $creaturehp - $playerdamage;
echo "For " . $playerdamage . " points of damage. <br>";
if ($newcreaturehp < 1)
{
echo "The " . $creature . " has been killed";
$updatecreature="DELETE from creatures where name='$creature' limit 1";
mysql_query($updatecreature) or die("Could not update creature");
echo "<a href='battle.php'>Go Back";
exit;
}
$updatecreature="update creatures set hpoints='$newcreaturehp' where name='$creature' limit 1";
mysql_query($updatecreature) or die("Could not update creature");
}
else
{
echo $playerinfo3['name'] . " misses!<br>";
}
//////////////////////creatures turn //////////////////
echo "<u> " . $creature . "'s Attack</u><br>";
$creatureattack = rand(1,20) + $creatureattack;
$playerdefense = rand(1,20) + $playerdefense;
echo $creature . "'s Attack roll is " . $creatureattack . "<br>";
echo $playerinfo3['name'] . "'s defense roll is " . $playerdefense . "<br>";
if ($creatureattack > $playerdefense)
{
echo $creature . " hits! <br>";
$creaturedamage = rand(1,6);
$newplayerhp = $playerhp - $creaturedamage;
echo "For " . $creaturedamage . " points of damage. <br>";
if ($newplayerhp < 1)
{
echo $playerinfo3['name'] . " has been killed<br>";
echo "<a href='gameover.php'>Continue";
exit;
}
$updateplayer="update players set hpoints='$newplayerhp' where name='player1'";
mysql_query($updateplayer) or die("Could not update player");
}
else
{
echo $creature . " misses!";
}
echo "<br><br><a href='battle.php?creature=$creature'>Battle Again!";
?>
hallsofvallhalla
Site Admin
Posts: 12026 Joined: Wed Apr 22, 2009 11:29 pm
Post
by hallsofvallhalla » Tue Oct 13, 2009 4:45 pm
no i mean up in the link, it should say localhost/tutorial/attack.php? then something
Ravinos
Posts: 281 Joined: Tue Sep 15, 2009 4:14 pm
Post
by Ravinos » Tue Oct 13, 2009 6:14 pm
Did you add (creature) to the players table? I think i got stuck there the first time too.
adamrain
Posts: 12 Joined: Sun Oct 11, 2009 7:51 pm
Post
by adamrain » Tue Oct 13, 2009 8:11 pm
Ravinos wrote: Did you add (creature) to the players table? I think i got stuck there the first time too.
what? i shold of done that? ill chack it out
halls:it dosnt show any "?" mark after the attack or battle in the comand line
Ravinos
Posts: 281 Joined: Tue Sep 15, 2009 4:14 pm
Post
by Ravinos » Tue Oct 13, 2009 10:28 pm
yes you need the a 'creature' added to the players structure with INT of 6 for it to store the creature.
adamrain
Posts: 12 Joined: Sun Oct 11, 2009 7:51 pm
Post
by adamrain » Wed Oct 14, 2009 1:26 pm
Ravinos wrote: yes you need the a 'creature' added to the players structure with INT of 6 for it to store the creature.
like that? it didnt work
adamrain
Posts: 12 Joined: Sun Oct 11, 2009 7:51 pm
Post
by adamrain » Wed Oct 14, 2009 1:55 pm
hallsofvallhalla wrote: ah then i think i know the problem, please post your battle.php here.
ok
Code: Select all
<?php
include 'connect.php';
$playerinfo="SELECT * from players where name='player1'";
$playerinfo2=mysql_query($playerinfo) or die("could not get player stats!");
$playerinfo3=mysql_fetch_array($playerinfo2);
$playerhp = $playerinfo3['hpoints'];
$playerattack = $playerinfo3['attack'];
$playerdefense = $playerinfo3['defense'];
if (isset($_GET['creature']))
{
$creature=$_GET['creature'];
$creatureinfo="SELECT * from creatures where name = '$creature'";
$creatureinfo2=mysql_query($creatureinfo) or die("could not get the creature you were fighting!");
$creatureinfo3=mysql_fetch_array($creatureinfo2);
}
else
{
$creatureinfo="SELECT * from creatures order by rand() limit 1";
$creatureinfo2=mysql_query($creatureinfo) or die("could get a creature!");
$creatureinfo3=mysql_fetch_array($creatureinfo2);
}
$creature = $creatureinfo3['name'];
$creaturehp = $creatureinfo3['hpoints'];
$creatureattack = $creatureinfo3['attack'];
$creaturedefense = $creatureinfo3['defense'];
/////player info
echo "<u> " . $playerinfo3['name'] . "</u><br>";
echo "Hit points = " . $playerhp . "<br>";
echo "Attack = " . $playerattack . "<br>";
echo "Defense = " . $playerdefense . "<br><br><br>";
///////creature info
echo "<u> " . $creatureinfo3['name'] . "</u><br>";
echo "Hit points = " . $creaturehp . "<br>";
echo "Attack = " . $creatureattack . "<br>";
echo "Defense = " . $creaturedefense . "<br><br><br>";
echo "<a href='attack.php?creature=$creature'>Attack!";
?>
hallsofvallhalla
Site Admin
Posts: 12026 Joined: Wed Apr 22, 2009 11:29 pm
Post
by hallsofvallhalla » Wed Oct 14, 2009 4:07 pm
on battle.php when you click attack, up top in the url it should say attack.php?creature= Does it not say that?
also i recommend going at least to video 7 before trying to run any of this. There is so much that changes in the source that it is easier. I would go all the way to video 14 then download the source if i was you, i include all of the source and mysql data.
adamrain
Posts: 12 Joined: Sun Oct 11, 2009 7:51 pm
Post
by adamrain » Wed Oct 14, 2009 6:50 pm
so you say "watch all the vids and download everthin at the end insted of doing it manualy" so thats what ill do...too bad i wanted to do it manualy.
oh and i forgat, thank you for everthin