Another Function/Array Problem[solved]

Place for questions and answers for all newcomers and new coders. This is a free for all forum, no question is too stupid and to noob.
Post Reply
User avatar
MikeD
Posts: 294
Joined: Thu Sep 08, 2011 4:28 am

Another Function/Array Problem[solved]

Post by MikeD »

Seems I find trouble everytime I try and simplify with functions.

Here's the function, it's to use a switch to get monster skill levels based on the dungeon level. I've echo'd out all the variables from inside the function and they work 100% correctly. However once I call the function and use a list, I can't get the values.

Here's the function, took a lot out of it so it wouldn't be a block of code.

Any help would be appreciated.

Code: Select all

function monsterstats($dunlvl,$realspeed,$realpower,$realmelee,$realmagic,$realarch,$realint,$realluck,$realagi,$realhp,$secondary)
{
switch($dunlvl)
 {
 case '1':
//blah
 break;
case '2':
//blah
$exp='2';
 break;
   case '3':
//blah
 break;
case '4':
//blah
 break;
 case '5':
//blah
 break;
 case '6':
//blah
 break;
  case '7':
//blah
 break;
  case '8':
//blah
 break;
 case '9':
//blah
 break;
  case '10':
//blah
 break;
 
  return array($monspeed,$monpower,$monmelee,$monmage,$monarch,$monint,$monluck,$monagi,$monsecondary,$monhp,$hpregen,$exp,$resethp);
}}

if ($dunlvl == '11')
{
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
elseif ($dunlvl != '11')
{
list($monspeed,$monpower,$monmelee,$monmage,$monarch,$monint,$monluck,$monagi,$monsecondary,$monhp,$hpregen,$exp,$resethp)=monsterstats($dunlvl,$realspeed,$realpower,$realmelee,$realmagic,$realarch,$realint,$realluck,$realagi,$realhp,$secondary);
echo $monspeed;
}
?>
Last edited by MikeD on Tue Nov 29, 2011 1:06 am, edited 1 time in total.
User avatar
MikeD
Posts: 294
Joined: Thu Sep 08, 2011 4:28 am

Re: Another Function/Array Problem

Post by MikeD »

Lol always figure these things out, and they are always simple things I overlooked.

Code: Select all

  return array($monspeed,$monpower,$monmelee,$monmage,$monarch,$monint,$monluck,$monagi,$monsecondary,$monhp,$hpregen,$exp,$resethp);
}}
should be

Code: Select all

  
}
return array($monspeed,$monpower,$monmelee,$monmage,$monarch,$monint,$monluck,$monagi,$monsecondary,$monhp,$hpregen,$exp,$resethp);
}
Post Reply

Return to “Beginner Help and Support”