How to make a level Interval?

Location of the Videos
Post Reply
User avatar
vitinho444
Posts: 2819
Joined: Mon Mar 21, 2011 4:54 pm

How to make a level Interval?

Post by vitinho444 »

Hey guys!

So i wanna make a thing:

You go to the wilderness (where the monsters are) then you are presented with some paths:
You Find Many paths to the Wilderness!
Choose one
Monsters Level 1-10
Monsters Level 1-20
Monsters Level 1-30
Monsters Level 1-50
Monsters Level 1-70
Monsters Level 1-90
Monsters Level 1-120

Choose well, you may die in the journey!
so thats all okay.. but i want to make a thing like this:
You Find Many paths to the Wilderness!
Choose one
Monsters Level 1-10
Monsters Level 10-20
Monsters Level 20-30
Monsters Level 30-50
Monsters Level 50-70
Monsters Level 70-90
Monsters Level 90-120

Choose well, you may die in the journey!
i made a battle.php for each interval

but all i need is an example so lets take battle90.php:
here's the important part:

Code: Select all

$mobinfo="SELECT * from monsters where level <= '90' order by rand() limit 1";
so how can i make a interval so it stays like this (this is not working i tryed it):

Code: Select all

$mobinfo="SELECT * from monsters where level <= '90' AND > '70' order by rand() limit 1";
My Company Website: http://www.oryzhon.com

Skype: vpegas1234
ConceptDestiny
Posts: 261
Joined: Wed Apr 28, 2010 8:35 am

Re: How to make a level Interval?

Post by ConceptDestiny »

Just a thought:

Why not set a rand variable for the levels outside the select query, then apply that level variable to the select query? i.e.

Code: Select all

if ($cave == 1)
{$level = rand(60,69);}
elseif ($cave == 2)
{$level = rand(70,89);}
etc.

$sql = mysql_query("SELECT * from monsters WHERE level = '$level'");
$row = mysql_fetch_array($sql);
$monster = $row['monster'];
I hope this helps. :)
User avatar
vitinho444
Posts: 2819
Joined: Mon Mar 21, 2011 4:54 pm

Re: How to make a level Interval?

Post by vitinho444 »

omg thats what im looking for

since i got a battle.php for each path i can make in each one this:

$level = rand(min, max);

then

$sql = mysql_query("SELECT * from monsters WHERE level = '$level'");

right?
My Company Website: http://www.oryzhon.com

Skype: vpegas1234
ConceptDestiny
Posts: 261
Joined: Wed Apr 28, 2010 8:35 am

Re: How to make a level Interval?

Post by ConceptDestiny »

vitinho444 wrote:omg thats what im looking for

since i got a battle.php for each path i can make in each one this:

$level = rand(min, max);

then

$sql = mysql_query("SELECT * from monsters WHERE level = '$level'");

right?
Yep. :) Mind If i take a look at your battle code to get a better idea of what you're trying to work towards?
User avatar
vitinho444
Posts: 2819
Joined: Mon Mar 21, 2011 4:54 pm

Re: How to make a level Interval?

Post by vitinho444 »

sure

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


<title>

The Legend of Kanisys

</title>


<?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'];

$name = $playerinfo3['name'];

$playerhp = $playerinfo3['hpoints'];

$playersp = $playerinfo3['spoints'];

$playerattack = $playerinfo3['attack'];

$playerdefense = $playerinfo3['defense'];



?>

<div id="table">

<?php
$plevel=$playerinfo3['level'];


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 ($stats == "hpoints"){

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

}



if ($stats == "spoints"){

$newsp = $statadd + $playersp;

if ($newsp > $playerinfo['maxspoints'])

{

$newsp = $playerinfo3['maxspoints'];

}

$updateplayersp="update players set spoints='$newsp' where id='$pid'";

  mysql_query($updateplayersp) or die("Could not update player");



    $updatesppot="DELETE from inventory where id='$pid' AND randid='$randid' limit 1";

  mysql_query($updatesppot) or die("Could not delete item");

   

   $playersp = $newsp;

 

  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

    {

    ////////////////////new for video 20

    if (isset($_GET['pllocation'])){

	

    $playerinfo3=$_GET['pllocation'];
	
	$plevel=$playerinfo3['level'];

    $arenainfo="SELECT * from locations where location='$pllocation' AND type='arena'";

    $arenainfo2=mysql_query($arenainfo) or die("Could not get arena");

    $areaninfo3=mysql_fetch_array($arenainfo2);

        $arenalevel = $arenainfo3['level'];
      $creatureselect = $playerinfo['level'];

            $creatureinfo="SELECT * from creatures where level <= '10' order by rand() limit 1";


            }else{
			

            $creatureinfo="SELECT * from creatures where level <= '10' 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");

    }









?>

</div>

<div id="player">

<?php

/////player info

echo "<h4><u> " . $playerinfo3['name'] . "</u><br>";

echo "Level = " . $playerinfo3['level'] . "<br>";

echo "Health = " . $playerhp . "<br>";

echo "Attack = " . $playerattack . "<br>";

echo "Defense = " . $playerdefense . "<br><br><br>";

?>

</div>

<div id="creature">

<?php

///////creature info

echo "<h4><u> " . $creatureinfo3['name'] . "</u><br>";

echo "Level = " . $creatureinfo3['level'] . "<br>";

echo "Health = " . $creatureinfo3['hpoints'] . "<br>";

echo "Attack = " . $creatureinfo3['attack'] . "<br>";

echo "Defense = " . $creatureinfo3['defense'] . "<br><br><br>";



echo "<a href='attack.php'><img src='images/attack.png'></a>";

echo "<br><a href='usemagic.php'><img src='images/usemagic.png'></a>";

echo "<br><a href='useitem.php'><img src='images/usepotion.png'></a>";

echo "<br><a href='run.php'><img src='images/back.png'></a>";





?>

</div>



<div id="logout">

<?php

echo "<br><a href='logout.php'><img src='images/logout.png'>";

?>

</div>
PS: give me a name for the credits page
My Company Website: http://www.oryzhon.com

Skype: vpegas1234
User avatar
vitinho444
Posts: 2819
Joined: Mon Mar 21, 2011 4:54 pm

Re: How to make a level Interval?

Post by vitinho444 »

just one more thing, if i make this:

$level = rand(1, 10);

monsters lvl 1 will appear or stating at lvl 2?
My Company Website: http://www.oryzhon.com

Skype: vpegas1234
ConceptDestiny
Posts: 261
Joined: Wed Apr 28, 2010 8:35 am

Re: How to make a level Interval?

Post by ConceptDestiny »

vitinho444 wrote:just one more thing, if i make this:

$level = rand(1, 10);

monsters lvl 1 will appear or stating at lvl 2?
It includes 1 and 10, and anything between.
vitinho444 wrote: PS: give me a name for the credits page
Na, it's fine. Glad I could help. :)
User avatar
vitinho444
Posts: 2819
Joined: Mon Mar 21, 2011 4:54 pm

Re: How to make a level Interval?

Post by vitinho444 »

kk thanks for everything
My Company Website: http://www.oryzhon.com

Skype: vpegas1234
User avatar
vitinho444
Posts: 2819
Joined: Mon Mar 21, 2011 4:54 pm

Re: How to make a level Interval?

Post by vitinho444 »

hey it doesnt work...

it doesnt find any creature

i think thats because i dont have the all interval of monsters...

how can i fix it?
My Company Website: http://www.oryzhon.com

Skype: vpegas1234
ConceptDestiny
Posts: 261
Joined: Wed Apr 28, 2010 8:35 am

Re: How to make a level Interval?

Post by ConceptDestiny »

What levels do you have creatures at?
Post Reply

Return to “Older Browser MMO Videos”