Page 10 of 13

Re: Video #4

Posted: Tue Feb 02, 2010 8:48 pm
by Chriillzz
error1.png
Always gets this error can someone help me please?

Re: Video #4

Posted: Tue Feb 02, 2010 8:52 pm
by Jackolantern
If you have the ID field set to auto-increment, take that out of your SQL insert statements. Also, in your VALUE brackets, don't start the list with a comma. A comma should only come after a value when you still have more to list.

Re: Video #4

Posted: Sun Feb 07, 2010 5:34 pm
by Bust
Plz keep up

PLZZ

Re: Video #4

Posted: Sun Feb 07, 2010 10:42 pm
by Jackolantern
Bust wrote:Plz keep up

PLZZ
Please keep what up? Halls' video tutorials? I know he is planning on releasing some more videos soon.

Re: Video #4

Posted: Fri Mar 05, 2010 1:47 am
by Mike9730
iam having a problem evrey time i press attack it just says player's attack on the top plz help

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!";
?>
thats the attack.php code

Re: Video #4

Posted: Fri Mar 05, 2010 3:49 am
by Mike9730
Mike9730 wrote:iam having a problem evrey time i press attack it just says player's attack on the top plz help

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!";
?>
thats the attack.php code
nvm i made a mistake by not copying

Code: Select all

echo $playerinfo3['name'] . "'s Attack roll is " . $playerattack . "<br>";
echo $creature . "'s defense roll is " . $creaturedefense. "<br>";

Re: Video #4

Posted: Fri Mar 19, 2010 11:19 pm
by Mike9730
how do you make it so it dosent delete the creature?

Re: Video #4

Posted: Sat Mar 20, 2010 2:04 am
by hallsofvallhalla
keep watching the videos, the fix comes.

Re: Video #4

Posted: Mon Jul 05, 2010 12:14 am
by Smuds
First I'd like to say these videos are really great and are kind of helping me along.

Second, I'd like to say that I have an error. I kind of had to go my own way with the attack script because I had a different idea for it to suit my game better.

But, being the beginner I am, I got an error and I have to limited of experience to fix it.

Parse error: parse error in C:\wamp\www\New Folder\attack.php on line 43

^^ Error
<?php
include 'connet.php';

$playerinfo="SELECT * from players where name='player1'";
$playerinfo2=mysql_query($playerinfo) or die ("could not get player stats!");
$playerinfo3=mysql_fetch_arra($playerinfo2);

if (isset($_GET['pokemon']))
{
$pokemon=$_GET['pokemon'];
$pokemoninfo="SELECT * from pokemon where name = '$pokemon'";
$pokemoninfo2=mysql_query($pokemoninfo) or die("could not get the pokemon you were fighting!");
$pokemoninfo3=mysql_fetch_array($pokemoninfo2);

}
else
{
echo "<a href='battle.php'>No Pokemon selected. Go Back!";
exit;
}
$playerhp = $playerinfo3['hpoints'];
$playerattack = $playerinfo3['attack'];
$playerdefense = $playerinfo3['defense'];

$pokemonhp = $pokemoninfo3['hpoints'];
$pokemonattack = $pokemoninfo3['attack'];
$pokemondefense = $pokemoninfo3['defense'];
//Players Turn
echo "<u><i>playerinfo3['name']<br />['level']
$playerattack = {rand(1,15) * (2*$playerattack)) - ($pokemondefence);
if $playerattack < 1
{
echo 'Your attack misses!';
}
$newpokemonhp = $pokemonhp - $playerattack
if $newpokemonhp < 1
{
echo You have defeated this pokemon and made it faint <br />
<a href='battle.php'>Go Back;
exit;
}
$updatepokemon='update creatures set hpoints'='$newpokemonhp' where name='$pokemon';
mysql_query[$updatepokemon];
My not completely finished attack script.

And yes, I did use Pokemon because I'm trying to make a Pokemon RPG :|

Re: Video #4

Posted: Mon Jul 05, 2010 1:39 am
by Callan S.
Mike9730 wrote:how do you make it so it dosent delete the creature?
Or you can use my changes, that I made after asking that same question: http://indie-resource.com/forums/viewto ... =26&t=1353