Hi. 🙂
I'm sure this is an easy fix but I think I've now been looking at this for too long. :oops:
Here's the code I have:
// First we must work out the rarity of the material found
$material_rand = rand(1,100);
if(($material_rand > '99') && ($material_rand < '101')) $material_selector = 28;
elseif(($material_rand > '89') && ($material_rand < '100')) $material_selector = 27;
elseif(($material_rand > '64') && ($material_rand < '90')) $material_selector = 2;
else $material_selector = 1;
// Now we need to pull out only the material item types which == $material_selector
$new_materials = array();
for($i = 0; ($i < count($materials)); $i++)
{
if($materials[$i]['item_type_use'] == $material_selector)
{
$new_materials[] = $materials[$i];
}
}
// Shuffle new array
$materials = shuffle($new_materials);
$material = $materials[0];
echo 'Mat Name: '.$material['material_name'];
So basically, I need to add the $materials[$i] onto the end of the $new_materials[] array each time the if() is true in the loop.
The $materials[$i] variable will consist of something similar to this:
$materials[] = array(
'material_name' => 'Glass',
'item_durability' => 0.50,
'item_power' => 1,
'item_weight' => 0.75,
'item_type_use' => 1,
'item_price' => rand(1,2),
Any help would be much appreiciated. 🙂