Page 1 of 1

Another Function/Array Problem[solved]

Posted: Tue Nov 29, 2011 12:58 am
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;
}
?>

Re: Another Function/Array Problem

Posted: Tue Nov 29, 2011 1:06 am
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);
}