PHP: <?phpdeclare(strict_types=1);namespace ExonCore\Spawn;use pocketmine\event\block\{BlockPlaceEvent, BlockBreakEvent};use pocketmine\event\Listener;use ExonCore\Core;class EventListener implements Listener{ private $plugin; public function __construct(Core $plugin){ $this->plugin = $plugin; $plugin->getServer()->getPluginManager()->registerevents($this, $plugin); } public function onPlace(BlockPlaceEvent $e){ $player = $e->getPlayer(); $x = $player->getX(); $y = $player->getY(); $z = $player->getZ(); if($x > 234 and $x < 282 and $y > 150 and $x < 118 and $z > 119 and $z < 58){ $e->setCancelled(); $player->sendMessage("You cant place"); } }} I went on 234 150 119 282 118 58 when i try break inside those coord it will break why...
So it’s PHP: public function onPlace(BlockPlaceEvent $e){ $player = $e->getPlayer(); $x = $player->getX(); $y = $player->getY(); $z = $player->getZ(); if($x > 234 and $x < 282 and $y > 118 and $x < 150 and $z > 58 and $z < 119){ $e->setCancelled(); $player->sendMessage("You cant place"); } }}
You mentioned you tried breaking the blocks on the following coordinates: 234 150 119 282 118 58 You will need to replace: > with >= < with <= >= stands for "greater than or equal to", <= stands for "lesser than or equal to"
Oh and ALSO, $x, $y and $z are player's coordinates. You should check for the block's coordinates ($event->getBlock()).
PHP: if($x >= 234 and $x <= 282 and $y >= 118 and $x =< 150 and $z >= 58 and $z <= 119){ err Code: ParseError: "syntax error, unexpected '<'" (EXCEPTION) in "ExonCore-Main/src/ExonCore/Spawn/EventListener" at line 27
PHP: public function onPlace(BlockPlaceEvent $e){ $player = $e->getPlayer(); $block = $e->getBlock(); $px = $player->getX(); $py = $player->getY(); $pz = $player->getZ(); $bx = $block->getX(); $by = $block->getY(); $bz = $block->getZ(); if($px >= 234 and $px <= 282 and $py >= 118 and $px <= 150 and $pz >= 58 and $pz <= 119){ $e->setCancelled(); $player->sendMessage("You cant place"); } if($bx >= 234 and $bx <= 282 and $by >= 118 and $bx <= 150 and $bz >= 58 and $bz <= 119){ $e->setCancelled(); $player->sendMessage("You cant plsace"); } } not working again
the problem may be ur checking the blocks x 3 times, try PHP: if($bx >= 234 and $bx <= 282 and $by >= 118 and $bz >= 58 and $bz <= 119){ $e->setCancelled(); $player->sendMessage("You cant plsace"); }