Hey there! How can i check if a player is in a area of 50 blocks from the world spawn? I need it for a farmworld protection. My current code: PHP: <?phpnamespace aenoxic\listener;use aenoxic\LordTown;use pocketmine\event\block\BlockBreakEvent;use pocketmine\event\Listener;class FarmweltProtection implements Listener { public $plugin; public function __construct(LordTown $plugin){ $this->plugin = $plugin; } public function onBreakFW(BlockBreakEvent $event){ $player = $event->getPlayer(); $level = $this->plugin->getServer()->getLevelByName("Liquide")->getSafeSpawn(); $levelx = $this->plugin->getServer()->getLevelByName("RED")->getSafeSpawn(); for ($x = $level->getFloorX() - 100; $x <= $level->getFloorX() + 100; $x++){ for ($y = $level->getFloorY() - 100; $y <= $level->getFloorY() + 100; $y++){ for ($z = $level->getFloorZ() - 100; $z <= $level->getFloorZ() + 100; $z++){ $event->setCancelled(); } } } }} Can anyone help me with some cool examples? Thanks alot!
If you want check square area, you can use this code PHP: if($player->getX() < $spawnX+50 && $player->getX() > $spawnX-50) { if($player->getZ() < $spawnZ+50 && $player->getZ() > $spawnZ-50) { // code }}