Browser MMO Video #20
- hallsofvallhalla
- Site Admin
- Posts: 12026
- Joined: Wed Apr 22, 2009 11:29 pm
Re: Video #20
thats because your sql password is blank, it is not NEWPASSWORD like mine was during the videos. As long as yours is working all is good.
Re: Video #20
alright thanks, and how do you import the sql file. I'm getting several errors and want to make sure i didnt miss anything in the db.
- hallsofvallhalla
- Site Admin
- Posts: 12026
- Joined: Wed Apr 22, 2009 11:29 pm
Re: Video #20
create a db, then go to import, choose the file, then upload. Default setting should be good to go.
Re: Video #20
K thanks got it to work. Had to change a small bit of coding, but not getting errors anymore. I'm not sure why but when i make another player they can't attack any creatures, if i go into the database there creature # is blank [if i make it 10 or 11 (10 orc, 11 wolf) then once i attack if i hit it says hit for 0 damage.] Has anyone else experienced this problem?
- hallsofvallhalla
- Site Admin
- Posts: 12026
- Joined: Wed Apr 22, 2009 11:29 pm
Re: Video #20
hmm not that I have seen but feel free to post code and we can look at it
Re: Video #20
Battle
attack.php
Code: Select all
<?php
include_once 'connect.php';
session_start();
include_once 'logo.php';
?>
<link href="style.css" rel="stylesheet" type="text/css" />
<div id="login2" div align="center">
<?php
if (isset($_SESSION['player']))
{
$player=$_SESSION['player'];
}
else
{
echo "Not Logged in <br><br> <A href='login.php'>Login</a>";
exit;
}
?>
</div>
<?php
$playerinfo="SELECT * from players where name='$player'";
$playerinfo2=mysql_query($playerinfo) or die("could not get player stats!");
$playerinfo3=mysql_fetch_array($playerinfo2);
$pllocation = $playerinfo3['location']; /// added line here.....
include_once 'statpanel.php';
$pid = $playerinfo3['id'];
$name = $playerinfo3['name'];
$playerhp = $playerinfo3['hpoints'];
$playerattack = $playerinfo3['attack'];
$playerdefense = $playerinfo3['defense'];
?>
<div id="table">
<?php
if (isset($_GET['randid']))
{
$randid=$_GET['randid'];
$iteminfo="SELECT * from inventory where randid='$randid' AND id ='$pid'";
$iteminfo2=mysql_query($iteminfo) or die("could not get item stats!");
$iteminfo3=mysql_fetch_array($iteminfo2);
if (!$iteminfo3['name'])
{
}
else
{
$iname = $iteminfo3['name'];
$stats = $iteminfo3['stats'];
$statadd = $iteminfo3['statadd'];
$type = $iteminfo3['type'];
if ($type == "healing")
{
$newhp = $statadd + $playerhp;
if ($newhp > $playerinfo3['maxhp'])
{
$newhp = $playerinfo3['maxhp'];
}
$updateplayer="update players set hpoints='$newhp' where id='$pid'";
mysql_query($updateplayer) or die("Could not update player");
$updateitem="DELETE from inventory where id='$pid' AND randid='$randid' limit 1";
mysql_query($updateitem) or die("Could not delete item");
$playerhp = $newhp;
echo "Used " . $iname . " and recovered " . $statadd . ".<br>";
}
}}
$creature = $playerinfo3['creature'];
if ($creature != 0)
{
$creatureinfo="SELECT * from creatures where id='$creature'";
$creatureinfo2=mysql_query($creatureinfo) or die("could not get the creature you were fighting!");
$creatureinfo3=mysql_fetch_array($creatureinfo2);
}
else
{
$areaninfo="SELECT * from locations where location='$pllocation' AND type='arena'";
$areaninfo2=mysql_query($areaninfo) or die("could not get arena");
$areaninfo3=mysql_fetch_array($areaninfo2);
$arenalevel = $areaninfo3['level'];
$creatureinfo="SELECT * from creatures where level <= '$arenalevel' order by rand() limit 1";
$creatureinfo2=mysql_query($creatureinfo) or die("could get a creature!");
$creatureinfo3=mysql_fetch_array($creatureinfo2);
$cid = $creatureinfo3['id'];
$updateplayer="update players set creature='$cid' where name='$name'";
mysql_query($updateplayer) or die("Could not update player");
}
$creature = $creatureinfo3['name'];
$creaturehp = $creatureinfo3['hpoints'];
$creatureattack = $creatureinfo3['attack'];
$creaturedefense = $creatureinfo3['defense'];
?>
</div>
<div id="player">
<?php
/////player info
echo "<u> " . $playerinfo3['name'] . "</u><br>";
echo "Hit points = " . $playerhp . "<br>";
echo "Attack = " . $playerattack . "<br>";
echo "Defense = " . $playerdefense . "<br><br><br>";
?>
</div>
<div id="creature">
<?php
///////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'>Attack</a>";
echo "<br><a href='usemagic.php'>Use Magic</a>";
echo "<br><a href='useitem.php'>Use Item</a>";
echo "<br><a href='index.php'>Exit Arena</a>";
?>
</div>
<div id="logout">
<?php
echo "<br><a href='logout.php'><img src='images/logout.gif'>";
?>
</div>
Code: Select all
<?php
include_once 'connect.php';
session_start();
include_once 'logo.php';
?>
<link href="style.css" rel="stylesheet" type="text/css" />
<div id="login2" div align="center">
<?php
if (isset($_SESSION['player']))
{
$player=$_SESSION['player'];
}
else
{
echo "Not Logged in <br><br> <A href='login.php'>Login</a>";
exit;
}
?>
</div>
<?php
$playerinfo="SELECT * from players where name='$player'";
$playerinfo2=mysql_query($playerinfo) or die("could not get player stats!");
$playerinfo3=mysql_fetch_array($playerinfo2);
include_once 'statpanel.php';
$pid = $playerinfo3['id'];
?>
</div>
<div id="table">
<?php
$creature = $playerinfo3['creature'];
if ($creature != 0)
{
$creatureinfo="SELECT * from creatures where id='$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'];
$playerpass = 0;
$creature = $creatureinfo3['name'];
$creaturehp = $creatureinfo3['hpoints'];
$creatureattack = $creatureinfo3['attack'];
$creaturedefense = $creatureinfo3['defense'];
?>
</div>
<div id="player">
<?php
///////////////////////players turn////////////////////
echo "<center><u> " . $playerinfo3['name'] . "'s Attack</u><br>";
if (isset($_GET['sid']))
{
$sid=$_GET['sid'];
$spellinfo="SELECT * from playermagic where sid='$sid' AND pid='$pid'";
$spellinfo2=mysql_query( $spellinfo) or die("could not get spell!");
$spellinfo3=mysql_fetch_array( $spellinfo2);
$sname = $spellinfo3['name'];
if ($spellinfo3['type'] == "combat")
{
if ($spellinfo3['scost'] > $playerinfo3['spoints'])
{
echo "You do not have enough Spell Points for this spell.<br>";
echo "<a href='battle.php'>Go Back";
exit;
}
else
{
$spoints = $spellinfo3['scost'];
$moddamage = $spellinfo3['svalue'] / 10;
$moddamage = (int)$moddamage;
$sdamage = $spellinfo3['svalue'];
$randdamage = rand(0, $sdamage);
$sdamage = $randdamage + $moddamage;
echo " You Cast " . $sname . " and do " . $sdamage . " points of damage";
$playerpass = 1;
$updateplayer="update players set spoints=spoints-'$spoints' where name='$player'";
mysql_query($updateplayer) or die("Could not update player");
}}
}
if ($playerpass = 1)
{
$weaponinfo="SELECT * from playerweapons where equip=1 AND pid='$pid'";
$weaponinfo2=mysql_query( $weaponinfo) or die("could not get player weapon!");
$weaponinfo3=mysql_fetch_array( $weaponinfo2);
$playerattack = rand(1,20) + $playerattack + $weaponinfo3['rating'];
//////////////////////////////////////////////////////
$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'] . " " . $weaponinfo3['hittext'] . " and hits!<br>";
$weapdamage = $weaponinfo3['damage'];
$halfdamage = $weaponinfo3['damage'] / 2;
$playerdamage = rand($halfdamage,$weapdamage);
$newcreaturehp = $creaturehp - $playerdamage;
echo "For " . $playerdamage . " points of damage. <br>";
if ($newcreaturehp < 1)
{
echo "The " . $creature . " has been killed";
$crmaxhp=$creatureinfo3['maxhpoints'];
$updatecreature="update creatures set hpoints='$crmaxhp' where name='$creature' limit 1";
mysql_query($updatecreature) or die("Could not update creature");
if ($playerinfo3['level'] > $creatureinfo3['level'])
{
$firstmod = $playerinfo3['level'] - $creatureinfo3['level'];
$secondmod = $firstmod * 10 ;
if ($secondmod > 90){$secondmod = 90;}
$thirdmod = ($secondmod / 100) * $creatureinfo3['exper'];
$totalexper =$creatureinfo3['exper'] - $thirdmod;
}
else
{
$firstmod = $creatureinfo3['level'] - $playerinfo3['level'];
$secondmod = $firstmod * 10 ;
if ($secondmod > 90){$secondmod = 90;}
$thirdmod = ($secondmod / 100) * $creatureinfo3['exper'];
$totalexper =$creatureinfo3['exper'] + $thirdmod;
}
$totalexper = (int)$totalexper;
echo "<br><b><big>You gain " . $totalexper . " experience.</b></big><br>";
$updateplayer="update players set exper=exper+'$totalexper',creature=0 where name='$player'";
mysql_query($updateplayer) or die("Could not update player");
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'] . " " . $weaponinfo3['hittext'] . " and misses!";
}}
?>
</div>
<div id="creature">
<?php
//////////////////////creatures turn //////////////////
echo "<center><u> " . $creature . "'s Attack</u><br>";
///////hit location//////////////////////////////////////
$randlocation = rand(0,100);
if ($randlocation <= 15)
{$location = "arms";}
elseif ($randlocation <= 70)
{$location = "chest";}
elseif ($randlocation <= 90)
{$location = "legs";}
elseif ($randlocation <= 100)
{$location = "head";}
$playerarmor="SELECT * from playerarmor where pid='$pid' AND location='$location' AND equip=1";
$playerarmor2=mysql_query($playerarmor) or die("Could not get player armmor");
$playerarmor3=mysql_fetch_array($playerarmor2);
$noarmor = 0;
if(is_null($playerarmor3['rating']))
{
$playerarmor3['rating'] = 0;
$noarmor = 1;
}
////////////////////////////////////
$creatureattack = rand(1,20) + $creatureattack;
$playerdefense = rand(1,20) + $playerdefense + $playerarmor3['rating'];
echo $creature . "'s Attack roll is " . $creatureattack . "<br>";
echo $playerinfo3['name'] . "'s defense roll is " . $playerdefense . "<br>";
if ($creatureattack > $playerdefense)
{
echo $creature . " hits for a strike to the " . $location . "<br>";
$creaturedamage = rand(1,6);
$newplayerhp = $playerhp - $creaturedamage;
echo "For " . $creaturedamage . " points of damage. <br>";
if ($noarmor == 1)
{
echo "You are not wearing armor on your " . $location . ".<br>";
$extradamage = rand(1,3);
echo "You take an additional " . $extradamage . " points of damage.<br>";
$newplayerhp = $newplayerhp - $extradamage;
}
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='$player'";
mysql_query($updateplayer) or die("Could not update player");
}
else
{
echo $creature . " misses!";
}
echo "<br><br><a href='battle.php?creature=$creature'>Battle Again!";
?>
</div>
- RogueTomboy
- Posts: 61
- Joined: Sun May 22, 2011 3:42 pm
Re: Video #20
I finished watching the video's 1-20 (amazing btw) and I was able to fix the usual 'how do I' errors but there is one that is giving me trouble.
I got the error about the bypass so I changed my bypass !=1 to bypass =1 and it fixed the isses BUT!!! now whenever I travel to a location by picking the Go to Map link instead of JUST showing the three usual places it now also has all the areas stuff.
Example:
It should only show -
Travel place 1
Travel place 2
Travel place 3
But it shows -
Travel place 1
Travel place 2
Travel place 3
CURRENT LOCATION
Visit store
visit inn
visit all other places, etc
go to map
Here is my code for the page:
I got the error about the bypass so I changed my bypass !=1 to bypass =1 and it fixed the isses BUT!!! now whenever I travel to a location by picking the Go to Map link instead of JUST showing the three usual places it now also has all the areas stuff.
Example:
It should only show -
Travel place 1
Travel place 2
Travel place 3
But it shows -
Travel place 1
Travel place 2
Travel place 3
CURRENT LOCATION
Visit store
visit inn
visit all other places, etc
go to map
Here is my code for the page:
Code: Select all
<?php
include_once 'connect.php';
session_start();
include_once 'logo.php';
?>
<link href="style.css" rel="stylesheet" type="text/css" />
<div id="login2" div align="center">
<?php
if (isset($_SESSION['player']))
{
$player=$_SESSION['player'];
}
else
{
echo "Not Logged in <br><br> <A href='login.php'>Login</a>";
exit;
}
?>
</div>
<?php
$playerinfo="SELECT * from players where name='$player'";
$playerinfo2=mysql_query($playerinfo) or die("could not get player stats!");
$playerinfo3=mysql_fetch_array($playerinfo2);
include_once 'statpanel.php';
?>
<div id ="locations">
<?php
$playerhp = $playerinfo3['hpoints'];
if ($playerhp < 1)
{
echo "You are dead!" ;
echo "<br><a href='useitem.php>Use an Item";
exit;
}
if(isset($_GET['map']))
{
$bypass=1;
echo "<a href='index.php?mapchange=1&mapname=Crocania'>Crocania</a><br>";
echo "<a href='index.php?mapchange=1&mapname=Fordale Woods'>Fordale Woods</a><br>";
echo "<a href='index.php?mapchange=1&mapname=Mintus Mountains'>Mintus Mountains</a><br>";
}
if(isset($_GET['mapchange']))
{
$bypass=1;
$mapname = $_GET['mapname'];
$updateplayer="update players set location='$mapname' where name='$playerinfo3[name]'";
mysql_query($updateplayer) or die("Could not update player");
echo "You have traveled to " . $mapname . ".<br>";
echo "<a href='index.php'>To location</a><br>";
}
if($bypass = 1)
{
echo "<b><big><u>" . $playerinfo3['location'] . "</u></big></b><br>";
echo "<a href='store.php'>Visit Store</a><br>";
echo "<a href='weaponshop.php'>Visit Weapon Shop</a><br>";
echo "<a href='armorshop.php'>Visit Armor Shop</a><br>";
echo "<a href='inn.php'>Visit Inn</a><br>";
echo "<a href='spelltrainer.php'>Visit Spell Trainer</a><br>";
echo "<a href='battle.php'>Battle in Arena</a><br>";
echo "<a href='index.php?map=1'>Go to Map</a><br>";
}
?>
</div>
<div id="logout">
<?php
echo "<br><a href='logout.php'><img src='images/logout.gif'></a>";
?>
</div>
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: Video #20
i think your problem is here
it says
you said you changed your bypass to =1 so its displaying everything that you told it to display if bypass = 1
i think the ! in
is there for a reason
idk i could be wrong.
it says
Code: Select all
if($bypass = 1)
{
echo:all your locations
}
i think the ! in
Code: Select all
if($bypass != 1)
{
echo:all locations
}
idk i could be wrong.
if you love something, let it go.
if it doesnt return.....hunt it down and kill it.
if it doesnt return.....hunt it down and kill it.
- RogueTomboy
- Posts: 61
- Joined: Sun May 22, 2011 3:42 pm
Re: Video #20
If I put the ! back in I get this error...
Notice: Undefined variable: bypass in C:\wamp\www\tutorial\index.php on line 60
Call Stack
# Time Memory Function Location
1 0.0004 381864 {main}( ) ..\index.php:0
Notice: Undefined variable: bypass in C:\wamp\www\tutorial\index.php on line 60
Call Stack
# Time Memory Function Location
1 0.0004 381864 {main}( ) ..\index.php:0
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
- hallsofvallhalla
- Site Admin
- Posts: 12026
- Joined: Wed Apr 22, 2009 11:29 pm
Re: Video #20
noooooo
all you have to do is put $bypass = 0; at the top of the page somewhere. Keep the original code the same!
all you have to do is put $bypass = 0; at the top of the page somewhere. Keep the original code the same!