Hi, I basically want to get a random number, but I want this number to be in an array. Basically... PHP: $ids = [3,5,27,53,87] Then, I need to get a random number that is one of the ints in that array.. Also, if you can tell me, how can I make an inventory array with lots of random numbers to put in a chest? So I have an array with the ids and data... I need help putting that in a big array.. (Separate for ids and data), then convert those 2 arrays in a inventory format so I can use setInventory() with that! Thanks in advance!!
Personally I like this more because it is faster. PHP: function random_array_value(array $array){ return $array[array_keys($array)[mt_rand(0, count($array))]];}
Basically, you know when you do PHP: $player->getInventory()->getContents(); That returns an array, that is in a format that allows to to do PHP: $player>getInventory()->setContents();
It's not called "format". It is called data type Use this: PHP: $id = $ids[mt_rand(0, count($ids)];$inventory->addItem(Item::get($id));