Videos 1-20

Location of the Videos
IceRidder
Posts: 11
Joined: Wed Oct 20, 2010 10:37 am

Re: Videos 1-20

Post by IceRidder »

i think if you watch all the videos you will find you answer.
the most common way to do it is create a session. You say that the player is already logged in but at some point he needs to log in as you cannot automatically do that and when he logs in you set the session and in battle just use "if isset".

hope this answers your question
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Re: Videos 1-20

Post by Jackolantern »

I concur. I think if you keep going in the videos you should have everything you need, because that separate combat file is merged back into the full game later. The player logs in and is stored in a session variable. Later they will be able to fight as part of the full game while logged in.
The indelible lord of tl;dr
User avatar
Kazz
Posts: 23
Joined: Thu Nov 04, 2010 2:58 am

Re: Videos 1-20

Post by Kazz »

alright thnx, i didn't know that as i am onIy on video 11, there wasnt enough time in the day to finish the rest of the videos, have been watching all the videos,there not completely clear of all the coding.
"What ever you do in life will be insignificant, but it is very important that you do it because no one else will." Gandhi
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Re: Videos 1-20

Post by Jackolantern »

I guess we haven't said it recently so it has slipped off of the most visible posts. Our typical mantra here is: "Just watch all the videos before even touching a code editor, and then re-watch them and start working with the code". You will be amazed at how much more sense it makes once you watch it all the way through. You will have a better idea of where the project is going, you will understand earlier parts better by seeing how they fit together later, and you will have seen the same 7 or 8 techniques used over and over, thus making you more comfortable with editing them as you see fit. :)
The indelible lord of tl;dr
User avatar
Kazz
Posts: 23
Joined: Thu Nov 04, 2010 2:58 am

Re: Videos 1-20

Post by Kazz »

Alright thnx :p Where his table of "Members is called players mine is called "Users"... Does that mean with the Battle.php, attack.php and store.php ect, where everything is called playerinfo, playerinfo2/3.. do i change mine to userinfo for all that? On my main game file, i have all the stats there and i use <?php echo 'Defence: '.$userinfo['defence'].''; ?><br> and it shows Perfect but when i do the version he does on the tutorials it doesnt sho anything for it.
"What ever you do in life will be insignificant, but it is very important that you do it because no one else will." Gandhi
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Re: Videos 1-20

Post by Jackolantern »

Whatever you name a column in MySQL must be the exact same name you reference it by in PHP, including upper vs. lower case.
The indelible lord of tl;dr
User avatar
Kazz
Posts: 23
Joined: Thu Nov 04, 2010 2:58 am

Re: Videos 1-20

Post by Kazz »

so would all those $playerinfo be $userinfo since my table of member is Users?

$playerinfo="SELECT * from players where name='player1'";
$playerinfo2=mysql_query($playerinfo) or die("could not get player stats!");
$playerinfo3=mysql_fetch_array($playerinfo2);
"What ever you do in life will be insignificant, but it is very important that you do it because no one else will." Gandhi
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Re: Videos 1-20

Post by Jackolantern »

Ohhh, I see what you mean. No, the variable name doesn't matter (anything with a '$' in front of it). Only things like that "player1", "players", and "name" have to exactly match. Things like the $playerinfo are swapped out for whatever value the variable is holding. However, those values being stored in the variable must match exactly.

EDIT: I mean what is in a variable if used as part of the query, like if it was "...WHERE name='$playername'", then the contents of $playername would have to match exactly what you want to pull up. In the case of your code, $playerinfo simply holds the SQL query, and could be named anything.
The indelible lord of tl;dr
User avatar
Kazz
Posts: 23
Joined: Thu Nov 04, 2010 2:58 am

Re: Videos 1-20

Post by Kazz »

I found the glitch myself... Where name="Kazz" i had to add username="Kazz" and a few spelling mistakes from the actuall file from the site :P Thnx for all yur help.
"What ever you do in life will be insignificant, but it is very important that you do it because no one else will." Gandhi
nozoner
Posts: 2
Joined: Sun Aug 28, 2011 7:25 pm

Re: Videos 1-20

Post by nozoner »

can you guys help he i keep getting this error
Undefined index: pclass in C:\wamp\www\tutorial\statpanel.php on line 4
Undefined index: gold in C:\wamp\www\tutorial\statpanel.php on line 15

this is how my statpanel.php looks like

Code: Select all

<div id="lpanel">
<?php
echo "<u><b> " . $playerinfo3['name'] . "</b></u><br>";
echo $playerinfo3['pclass'] . "<br>";
//////////////new for 17
echo "Level " . $playerinfo3['level'] . "<br>";



echo "Attack = " . $playerinfo3['attack'] . "<br>";
echo "Defense = " . $playerinfo3['defense'] . "<br>";
echo "Hit Points<br>";
echo "Spell Points<br><br>";
echo "<b><big><u>Gold</u></big></b><br>";
echo $playerinfo3['gold'];
?>
<?php
echo "<br><br>";
echo "<a href='equipment.php?equip=1'>Equipment<br></a>";
echo "<a href='equipment.php?backpack=1'>Backpack<br></a>";
echo "<a href='profile.php'>Profile<br></a>";
$i = 0;
$messageinfo="SELECT pid from messages where pid='$player' AND readm = '1'";
    $messageinfo2=mysql_query($messageinfo) or die("Could not get user stats");
    while($messageinfo3=mysql_fetch_array($messageinfo2))
	{$i = $i + 1;}
if($i > 0){echo "<a href='profile.php?messages=1'>Messages(" . $i . ")</a><br>";}
else{echo "<a href='profile.php?messages=1'>Messages<br></a>";}
////////////////////////new for video 17////////////////
echo"<br>";
 $expneeded = ($playerinfo3['level'] * 100) * $playerinfo3['level'];
  if ($playerinfo3['exper'] >= $expneeded)
 {	echo "<br><a href='levelup.php'>Level Up!!</a>";}
?>
</div>


<div id= "hpointsback">
<?php
echo "<img src='images/barback.png'>";
?>
</div>

<div id= "hpoints">
<?php
$width = ($playerinfo3['hpoints'] / $playerinfo3['maxhp']) * 100;
echo "<img src='images/hpoints.png' width='$width' height='15' >";
?>
</div>

<div id= "spointsback">
<?php
echo "<img src='images/barback.png'>";
?>
</div>

<div id= "spoints">
<?php
$width = ($playerinfo3['spoints'] / $playerinfo3['maxspoints']) * 100;
echo "<img src='images/spoints.png' width='$width' height='15' >";
?>
</div>

Post Reply

Return to “Older Browser MMO Videos”