• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Help with Arrays

Avarian

Bring Out Your Dead!
Joined
Jun 14, 2007
Messages
472
Reaction score
1
Location
United States
I've never played with Arrays till now and it's not working so I could really use some help.

I'll make a small example so that I don't have to post my whole script. If this isn't helpful in pointing out what i'm doing wrong then i'll just post the actual script.


PHP:
// These are small example rays. 
$creatures = array("rat"=>5,"cave rat"=>10); 
$levels = array("1"=>0,"2"=>200,"3"=>400); 

//Then there's a form to retrieve user input 
$current_exp = $_POST['current_exp']; 
$lvl_desired = $_POST['lvl_desired']; 
$creature = $_POST['creature']; 

//This variable is suppose take the user inputed lvl_desired and check it in the $levels array and then the exp from that level is the variable $lvlEXP_amount how ever this variable keeps returning blank 
$lvlEXP_amount = $levels['$lvl_desired']; 

// This variable figures out exp required to advance to the desired level. 
$neededForAdvance = $lvlEXP_amount / $current_exp; 

//This variable is suppose take the user inputed creature and check it in the $creatures array and then the exp from that creature is the variable $lcreatureEXP_amount how ever this variable keeps returning blank as well. 
$creatureEXP_amount = $creatures['$creature']; 

// This variable figures out how many of the user inputed creature needs to be killed to reach the lvl_desired. 
$numberCreaturesToKill = $neededForAdvance / $creatureEXP_amount;
 
Firstly, there is no need to store experience for each level : O

Function from nicaw acc:
Code:
	public function getExperienceByLevel($lvl)
	{
		return floor(50*($lvl-1)*($lvl*$lvl-5*$lvl+12)/3);
	}

remember also, to increase monster exp by ExpRate :)

Also to get best precise, you could do it by player name, not only by lev, as its not equals.

Next thing, experience could be loaded from monster.xml file

ahh thats could be really advanced ;p
 
Last edited:
Everything you said has nothing to do with the script I was making, in fact the script has nothing to do with tibia or OT lol

but thanks for posting, someone pointed out my mistake. :p
 
Back
Top