So I remade it in the way you told me and now it looks like this:
<?php
include ('config.php');
$playerlvl = Rand (2, 100)-1;
$chance = Rand (0,10000)-1;
$itemstats = array( "str", "dex", "int", "sta", "hp", "mp");
echo "Hello LVL $playerlvl adventurer! </br>";
//Function that generates stats,$playerlvl, $qmulti, $itemstats, $itemtype are stated out of the function
function statgen($playerlvl, $qmulti, $itemstats, $itemtype) {
$data = array();
if ($itemtype == "weapon") {
$data['minwdmg'] = 10 + 3 * $playerlvl * ($qmulti/2);
$data['maxwdmg'] = 20 + 3 * $playerlvl * ($qmulti/2);
$data['statt1'] = $itemstats[rand(0,5)];
$data['statt2'] = $itemstats[rand(0,5)];
$data['stat1'] = $playerlvl * ($qmulti/2);
$data['stat2'] = $playerlvl * ($qmulti/2);
}
else {
$data['statAR'] = $playerlvl * 3/2 + rand(0, 10);
$data['statt1'] = $itemstats[rand(0,5)];
$data['statt2'] = $itemstats[rand(0,5)];
$data['stat1'] = $playerlvl * ($qmulti/2);
$data['stat2'] = $playerlvl * ($qmulti/2);
}
return $data;
}
// Gets itemqlvl, if its==0 than does nothing, else creates item
if ($chance <= 10){
$itemqlvl = 3;
}
elseif ($chance <= 100){
$itemqlvl = 2;
}
elseif ($chance <= 9000) {
$itemqlvl = 1;
}
else {
$itemqlvl = 0;
}
//echo "$chance </br>";
switch($itemqlvl){
case "0":
echo "Monster didnt drop anything";
break;
case "1":
$quality = "common";
$qmulti = 2;
break;
case "2":
$quality = "enchanted";
$qmulti = 3;
break;
case "3":
$quality = "elite";
$qmulti = 4;
break;
}
if ($itemqlvl >= 1) {
$itemtypes = array( "weapon", "body", "legs", "feet", "hands", "head");
$itemtype = $itemtypes[rand(0, 5)];
statgen($playerlvl, $qmulti, $itemstats, $itemtype);
}
//Prints out results/tests.
if ($itemqlvl >= 1) {
echo "You searched monsters body and found $quality $itemtype!</br>";
}
if ($itemtype == "weapon"){
echo "Dmg: $data['minwdmg'] - $data['maxwdmg'] </br>$data['statt1'] - $data['stat1'] </br> $data['statt2'] - $data['stat2']";
}
if ($itemtype != "weapon") {
echo "Armor: $data['statAR'] </br>$data['statt1'] - $data['stat1'] </br> $data['statt2'] - $data['stat2']";
}
?>
But now I got this error, and I don't even have an idea, what is a parse error (my english isn't good enough and I'm also poor proggammer... for now 🙂 )
Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in C:\wamp\www\Game\itemgen.php on line 74
P.S. Btw, I cant seam to find edit button for my posts XD