Hello pmmp, I am trying to get a random level from the config, I have this: PHP: $this->arenas = $config->get("arenas");foreach($this->arenas as $lev);$this->newgame = $lev[mt_rand($lev)]; but I keep getting this error when the plugin starts up: Code: [20:33:39] [Server thread/CRITICAL]: ErrorException: "mt_rand() expects exactly 2 parameters, 1 given" (EXCEPTION) in "sg/src/SurvivalGamesV2/SurvivalGamesV2" at line 63 [20:33:39] [Server thread/DEBUG]: #0 (): pocketmine\error_handler(integer 2, string mt_rand() expects exactly 2 parameters, 1 given, string C:\Users\Admin\Creative Cloud Files\Desktop\Lobby - DEV\plugins\sg\src\SurvivalGamesV2\SurvivalGamesV2.php, integer 63, array Array()) [20:33:39] [Server thread/DEBUG]: #1 sg/src/SurvivalGamesV2/SurvivalGamesV2(63): mt_rand(string sgtest) [20:33:39] [Server thread/DEBUG]: #2 src/pocketmine/plugin/PluginBase(90): SurvivalGamesV2\SurvivalGamesV2->onEnable() [20:33:39] [Server thread/DEBUG]: #3 DevTools (2).phar/src/FolderPluginLoader/FolderPluginLoader(127): pocketmine\plugin\PluginBase->setEnabled(boolean 1) [20:33:39] [Server thread/DEBUG]: #4 src/pocketmine/plugin/PluginManager(610): FolderPluginLoader\FolderPluginLoader->enablePlugin(SurvivalGamesV2\SurvivalGamesV2 object) [20:33:39] [Server thread/DEBUG]: #5 src/pocketmine/Server(1955): pocketmine\plugin\PluginManager->enablePlugin(SurvivalGamesV2\SurvivalGamesV2 object) [20:33:39] [Server thread/DEBUG]: #6 src/pocketmine/Server(1941): pocketmine\Server->enablePlugin(SurvivalGamesV2\SurvivalGamesV2 object) [20:33:39] [Server thread/DEBUG]: #7 src/pocketmine/Server(1735): pocketmine\Server->enablePlugins(integer 1) [20:33:39] [Server thread/DEBUG]: #8 src/pocketmine/PocketMine(554): pocketmine\Server->__construct(BaseClassLoader object, pocketmine\utils\MainLogger object, string C:\Users\Admin\Creative Cloud Files\Desktop\Lobby - DEV\, string C:\Users\Admin\Creative Cloud Files\Desktop\Lobby - DEV\plugins\) [20:33:39] [Server thread/DEBUG]: #9 C:/Users/Admin/Creative Cloud Files/Desktop/Lobby - DEV/PocketMine-MP.phar(1): require(string phar://C:/Users/Admin/Creative Cloud Files/Desktop/Lobby - DEV/PocketMine-MP.phar/src/pocketmine/PocketMine.php) what do I do, I'm very confused
Also, how would I then save that random level as a variable? edit: would this be correct: PHP: $this->arenas = $config->get("arenas");$level = $this->arenas;$this->newgame = $level[array_rand($level)];
Yeah I did, I just thought by using $this->newgame it would run random again but it doesn't because it happens on server enable