I'm trying to use a config file to store a minimum and maximum value that can be changed by users for easier changing of a randomizing code. This is being used for a PocketMine-MP plugin that will spawn a player at a random position and have their spawn at the random location.
My config file looks like this:
##Change These Listed Numbers To Change Your Spawn Randomizers min and Maxes
-Coords:
Xvalues:
Xmin: -10000
Xmax: 10000
Yvalues:
Ymin: -10000
Ymax: 10000
Zvalues:
Zmin: -10000
Zmax: 10000
...
I know this works but when I use these values and make them a variable and use that variable in a mt_rand()
function I get a error saying:
[21:26:18] [Server thread/CRITICAL]: TypeError: "mt_rand() expects parameter 1 to be int, bool given" (EXCEPTION) in "plugins/TPRandomOnFirstJoinAndDeath/src/JviguyGamesYT/TPRandomOnFirstJoinAndDeath/Main" at line 27
I don't really know what to do to fix this. If anyone could help my code for the plugin, here's the code:
$player = $e->getPlayer();
$Xmin = $this->getConfig()->get("Xmin");
$Xmax = $this->getConfig()->get("Xmax");
$Ymin = $this->getConfig()->get("Ymin");
$Ymax = $this->getConfig()->get("Ymax");
$Zmin = $this->getConfig()->get("Zmin");
$Zmax = $this->getConfig()->get("Zmax");
$x = mt_rand($Xmin , $Xmax);
$y = mt_rand($Ymin , $Ymax);
$z = mt_rand($Zmin , $Zmax);
$player->teleport(new vector3($x, $y, $z));