For all Mac users out there

Location of the Videos
User avatar
windextor
Posts: 40
Joined: Sun Mar 28, 2010 8:50 pm

For all Mac users out there

Post by windextor »

Hello!

I'm not sure if I'm posting this on the right thread, because it's not actually a question - it was a question before I solved it myself (although I don't know how I did it :D)

I've recently joined this forums and started watching Halls' video tutorials on how to make an MMORPG, and I'm currently on a learning process from scratch.

I've actually watched all the videos before doing anything to kind of see where it is all going, and I'm now re-watching them to actually get on with the coding myself.

The thing is, I'm currently on a MacBook Pro 13" with OS X 10.6.2, so my software environment is different. I'm not a Mac fan-boy or anything like that. I've actually had this laptop for two months now and so far, although it does have some cool features, I'm largely unimpressed. I bought it out of curiosity because I needed a laptop for work. Ironic huh?

I started by searching the equivalent of WAMP for Mac, which wasn't difficult at all (turns out it's called MAMP actually, so no biggie there) and downloading it:

http://www.mamp.info/en/index.html

So far so good.

I followed the instructions on the first video and my test.php worked perfectly.

Image

On the second video though I ran into a problem.

For some reason after creating the connect.php and changing the test.php with the exact same code as the videos, I'd always get a "Could not access database" error:

Image

Image

Image

I investigated further because it could happen that for MAMP the default user and localhost names were not exactly the same, but I believe that was not the case:

Image

I solved it by adding another user to the tutorial database on the privileges tab...

I created user James with password 1234:

Image

And changed the connect.php accordingly:

Image

And it worked.

Image

Now I'm sure I went through a huge amount of unnecessary steps, but I'm a total noob on this grounds, and I tried to solve it as best I could.

Any comments on this process are appreciated. Also tell me if you dislike such image-intensive posting on this forums and I will use as few screenshots as I can to still keep things understandable in the future. I'm new here so please be gentle :D

As a final thought, my idea is to go through all of the tutorial videos on my Mac environment and document my own journey so it can be of use to future Mac users around here.

Sorry for the long post, and once again, any input is appreciated.

Thank you for reading!
Last edited by windextor on Fri Jun 11, 2010 11:41 pm, edited 3 times in total.
User avatar
hallsofvallhalla
Site Admin
Posts: 12031
Joined: Wed Apr 22, 2009 11:29 pm

Re: For all Mac users out there

Post by hallsofvallhalla »

i will sticky this, I would love for you to document the mac process.
Genaga
Posts: 86
Joined: Fri Dec 11, 2009 7:05 pm

Re: For all Mac users out there

Post by Genaga »

To be honest, well done to you sir.

You had a problem and you fixed it. With a bit of help from google and common sense instead of coming on the forum moaning and demanding stuff so hats off to you for debugging.

Wish you the best of luck with the rest of the tutorials.
User avatar
Torniquet
Posts: 869
Joined: Sun Aug 02, 2009 6:18 am

Re: For all Mac users out there

Post by Torniquet »

by the looks of it. your root user has a password attached to it. this is where i think you would have got your errors from.

jus for reference.. there is wamp, lamp and mamp, there might be another one but i cant remember it.... but depending on your OS, does depend on the server u need... wamp (windows apache mysql and php server) lamp (linux apache mysql and php server) and mamp (mac apache mysql and php server).

just incase anyone gets stuck with not having wamp work when they are using a linux server etc :)


gratz on sorting it out yourself though. i really do wish others would atleast attempt to have ago at it before posting sometimes :D
New Site Coming Soon! Stay tuned :D
jpoisson
Posts: 245
Joined: Sun Aug 02, 2009 5:12 pm

Re: For all Mac users out there

Post by jpoisson »

The other is XAMPP, it is a cross platform set of of the software normally included in WAMP,LAMP,MAMP.

Xampp has also other upgrades like using perl and other scripting language.
User avatar
Noctrine
Posts: 928
Joined: Thu Apr 23, 2009 9:57 pm

Re: For all Mac users out there

Post by Noctrine »

I recommend Coda for mac development. But yeah, your issue was a password was attached to the Mamp root user. Better security and all that, congrats on figuring it out.
Jesse Dorsey
ProjectANI - Lead Developer Person
http://about.me/jessedorsey
User avatar
windextor
Posts: 40
Joined: Sun Mar 28, 2010 8:50 pm

Re: For all Mac users out there

Post by windextor »

Hey guys!

Thanks a lot for all the positive replies. I'm glad to contribute back to the community in whatever way I can.

First of all there's a little something I forgot to mention before: the file paths for MAMP are also not exactly the same as WAMP.

If you're struggling (like I did) to find that sneaky index.php file, go to your Applications folder. There should be a MAMP folder there (you dragged it during installation remember?)

Image

Inside the MAMP folder go to bin and then mamp again (lowercase). There's the index.php, and there's where I created my tutorial folder (making my default path for this experiments http://localhost:8888/MAMP/tutorial/file_example.php). I suppose you could place it anywhere else inside the bin folder provided you adjust your URL accordingly, but I'm not sure about this.

Alternatively, if you're not retarded like me, you can use the extremely handy search function and search for "index.php". It's going to be the top pick. Surprisingly this only occurred to me while writing this post :D

I know it sounds really basic but that's something I actually got stuck on for many more minutes than I should have, and I wanted to cover everything from a beginner's perspective.

Also, guess what I just found sitting right on MAMP's start page:

Image

The solution was in front of my eyes this whole time :lol:

Regarding the tutorial videos themselves, I've moved on to 3a and 3b without any major problems. Pretty straightforward coding.

I did get a "could not register" error for quite some time before realizing that I hadn't input a password field on my players table, so this snippet was always failing:

Code: Select all

    $SQL = "INSERT into players(name, password, email, level, exper) VALUES ('$player','$password','$email','1','0')";
          mysql_query($SQL) or die("could not register");
That's the frustrating bit about programming I guess. So far all the mistakes I made were absolutely trivial and unnecessary, and even the smallest of details can set you off for quite a long time.
Last edited by windextor on Fri Apr 02, 2010 8:47 pm, edited 1 time in total.
User avatar
windextor
Posts: 40
Joined: Sun Mar 28, 2010 8:50 pm

Re: For all Mac users out there

Post by windextor »

Hey!

I'm now at video 6, adding level and experience to the creatures and players.

I was stuck at one point where I'd always get a "Could not update player" with this code on attack.php:

Code: Select all

    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";
		 
		 //
		 
		         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");
  
  //
           
            $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;
       }
The experience was calculated and displayed correctly, but the player's experience field would never get updated (always remaining zero).

I finally got it working by simply copy pasting the attack.php code available on the "video 7" topic:

Code: Select all

 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");


        //////////////////////video 6////////////////////////
            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' where name='$player'";
      mysql_query($updateplayer) or die("Could not update player");



          echo "<a href='battle.php'>Go Back";
          exit;
       }
So it's great that it works and all, but I can't seem to understand why the previous code was not working and I'm not happy with that. Any ideas?
User avatar
hallsofvallhalla
Site Admin
Posts: 12031
Joined: Wed Apr 22, 2009 11:29 pm

Re: For all Mac users out there

Post by hallsofvallhalla »

try

Code: Select all

 $updateplayer="update players set exper = exper+'$totalexper',creature='0' where name='$player'";
  mysql_query($updateplayer) or die("Could not update player");
User avatar
windextor
Posts: 40
Joined: Sun Mar 28, 2010 8:50 pm

Re: For all Mac users out there

Post by windextor »

Both files have that code.

EDIT: actually, if I'm not mistaken, I believe both codes are exactly the same, except for the order of things.
Post Reply

Return to “Older Browser MMO Videos”