Page 1 of 1

Creature Question

Posted: Tue Sep 13, 2011 8:41 pm
by Huezzer
Hey all!, I've got a fast question about the creatures thing. How it is possible with a code to just make some of the creatures to "fight able" in one speciall place

Like this: I'm in the Forest and I don't want to make it able to kill a jellyfish in the Forest just in the Water(name of the place). I've started to do this in the database (Location) but don't kno how i can go forward.

if playerinfo3[location] = Forest <---- If this is right, I don't know how to continue..Anyway I don't know really :S Sorry

Thanks, Huezzer

Re: Creature Question

Posted: Tue Sep 13, 2011 9:10 pm
by Jackolantern
Just add the location the monster is supposed to be fought at in the SQL query:

Code: Select all

SELECT * FROM `monsters` WHERE `location` = `$currentLocation` 
Add in whatever else you want to search by into the SQL query. For example, to pull up only 1 monster within 5 levels of the player, you would do something like this:

Code: Select all

$minLevel = $playerLevel - 5;
$maxLevel = $playerLevel + 5;
$sql = "SELECT * FROM `monsters` WHERE `location` = `$currentlocation` AND `level` >= $minLevel AND `level` <= $maxLevel ORDER BY RAND() LIMIT 1";
$sql2 = mysql_query($sql);
$sql3 = mysql_fetch_assoc($sql2); 
Then you will have one random monster, fightable only in the current location, within 5 levels of the player.