Im working ona custom protection plugin and the event isnt cancelling/working, the coords are right in the config and everything, no errors, just doesnt work,CODE: PHP: <?phpnamespace Junkdude;use Junkdude\Shop;use Junkdude\EntityDamage;use pocketmine\block\Block;use pocketmine\event\block\SignChangeEvent;use pocketmine\event\player\{ PlayerGameModeChangeEvent, PlayerChatEvent, PlayerCommandPreprocessEvent, PlayerDeathEvent, PlayerHungerChangeEvent, PlayerInteractEvent, PlayerItemConsumeEvent, PlayerItemHeldEvent, PlayerLoginEvent, PlayerQuitEvent, PlayerDropItemEvent};use pocketmine\event\entity\{ EntityArmorChangeEvent, EntityDamageByEntityEvent, EntityDamageEvent, EntityTeleportEvent, EntityExplodeEvent, ExplosionPrimeEvent, EntitySpawnEvent, EntityRegainHealthEvent};use pocketmine\level\particle\{ AngryVillagerParticle, BubbleParticle, CriticalParticle, DustParticle, EnchantParticle, EnchantmentTableParticle, ExplodeParticle, FlameParticle, FloatingTextParticle, GenericParticle, HappyVillagerParticle, HeartParticle, HugeExplodeParticle, InkParticle, InstantEnchantParticle, ItemBreakParticle, LargeExplodeParticle, LavaDripParticle, LavaParticle, MobSpawnParticle, Particle, PortalParticle, RedstoneParticle, SmokeParticle, SplashParticle, SporeParticle, TerrainParticle, WaterDripParticle, WaterParticle};use pocketmine\event\Listener;use pocketmine\item\enchantment\Enchantment;use pocketmine\inventory\ShapedRecipe;use pocketmine\item\Item;use pocketmine\level\Position;use pocketmine\math\Vector3;use pocketmine\Player;use pocketmine\plugin\PluginBase;use pocketmine\utils\TextFormat as TF;use pocketmine\Server;use pocketmine\nbt\NBT;use pocketmine\level\format\FullChunk;use pocketmine\entity\Entity; use pocketmine\entity\Human; use pocketmine\nbt\tag\ByteTag; use pocketmine\nbt\tag\CompoundTag; use pocketmine\nbt\tag\DoubleTag; use pocketmine\nbt\tag\FloatTag; use pocketmine\nbt\tag\IntTag; use pocketmine\nbt\tag\ListTag; use pocketmine\nbt\tag\ShortTag; use pocketmine\nbt\tag\StringTag; use pocketmine\entity\Villager;use pocketmine\utils\Config;use pocketmine\tile\{ Tile, Chest, MobSpawner};use pocketmine\math\AxisAlignedBB;use pocketmine\event\block\BlockBreakEvent;use pocketmine\event\block\BlockPlaceEvent;use pocketmine\command\{ Command, CommandSender, ConsoleCommandSender};class Main extends PluginBase implements Listener{ public function onEnable() { ##EXTERNAL PLUGIN ROUTES### $this->getServer()->getPluginManager()->registerEvents($this, $this); $this->getServer()->getPluginManager()->registerEvents(new Rewards($this), $this); $this->getServer()->getPluginManager()->registerEvents(new EntityDamage($this), $this); $this->getServer()->getPluginManager()->registerEvents(new EventListener($this), $this); ##CONFIG STUFF## @mkdir($this->getDataFolder()); $cfg = new Config($this->getDataFolder() . "xyz.yml", Config::YAML); $data = $cfg->get("X1", "X2", "Y1", "Y2", "Z1", "Z2"); $file = ($this->getdatafolder() . "xyz.yml"); if(!file_exists($file)){ $cfg->set("X1", 100); $cfg->set("X2", 100); $cfg->set("Y1", 100); $cfg->set("Y2", 100); $cfg->set("Z1", 100); $cfg->set("Z2", 100); $cfg->save(); }}public function break(BlockBreakEvent $event){ $p = $event->getPlayer(); $cfg = new Config($this->getDataFolder() . "xyz.yml", Config::YAML); $x = $p->getX(); $y = $p->getY(); $z = $p->getZ(); $x1 = $cfg->get("X1"); $x2 = $cfg->get("X2"); $y1 = $cfg->get("Y1"); $y2 = $cfg->get("Y2"); $z1 = $cfg->get("Z1"); $z2 = $cfg->get("Z2"); if($x1 <= $x and $x <= $x2 and $y1 <= $y and $y <= $y2 and $z1 <= $z and $z <= $z2){ $event->setCancelled(true); $p->sendmessage("test"); }else if(!$x1 <= $x and $x <= $x2 and $y1 <= $y and $y <= $y2 and $z1 <= $z and $z <= $z2){ $p->sendmessage("NBHKMBL"); }}}
Nothing, it's a magic constant... are you sure you know the basics of PHP yet? why are you developing plugins?
The use print_r(), Player::sendMessage(), $this->getLogger()->info() or $this->getServer()->broadcastMessage() instead of var_dump().
Me too, same goes for my first programming language I learned, but I cant go without PHP.net, seriously have you never wondered how to chunk an array in parts or what functions a library has? You will surely need it in the future.
And what does it output? If __LINE__ somehow doesn't work, then use numbers for each dump, so you can identify them by the number and look up which conditions were executed by checking if their dump was broadcasted.
KKm i took out the lines that are hashtagged and it worked, it has something to do with the lines or variables PHP: public function break(BlockBreakEvent $event){ $p = $event->getPlayer(); $cfg = new Config($this->getDataFolder() . "xyz.yml", Config::YAML); $x = $p->getX(); $y = $p->getY(); $z = $p->getZ(); $x1 = $cfg->get("X1"); $x2 = $cfg->get("X2"); $y1 = $cfg->get("Y1"); $y2 = $cfg->get("Y2"); $z1 = $cfg->get("Z1"); $z2 = $cfg->get("Z2"); ##if($x1 <= $x and $x <= $x2 and $y1 <= $y and $y <= $y2 and $z1 <= $z and $z <= $z2){ $p->sendmessage("test"); ##}else if(!$x1 <= $x and $x <= $x2 and $y1 <= $y and $y <= $y2 and $z1 <= $z and $z <= $z2){ $p->sendmessage("NBHKMBL"); ##}}}
trying to cancel an event if a player is in those coords/out of them. The values are in my config Code: --- X1: 214 Y1: 74 Z1: 1 X2: 210 Y2: 69 Z2: 4 ...
Here's something: PHP: if($p->x >= $this->min[0] and $p->x <= $this->max[0] and $p->y >= $this->min[1] and $p->y <= $this->max[1] and $p->z >= $this->min[2] and $p->z <= $this->max[2]){$p->sendMessage("You are in a region");} else {$p->sendMessage("You are not in a region!");}} Don't copy it, but instead, learn from it... Well, You can. Just define the vars, and such....
Still not doing anything PHP: public function break(BlockBreakEvent $event){ $p = $event->getPlayer(); $cfg = new Config($this->getDataFolder() . "xyz.yml", Config::YAML); $x = $p->getX(); $y = $p->getY(); $z = $p->getZ(); $x1 = 214; $x2 = 210; $y1 = 74; $y2 = 69; $z1 = 1; $z2 = 4; if($x >= $x1 and $x <= $x2 and $y >= $y1 and $y <= $y2 and $z >= $z1 and $z <= $z2){ $p->sendmessage("In Region"); }else if(!$x >= $x1 and $x <= $x2 and $y >= $y1 and $y <= $y2 and $z >= $z1 and $z <= $z2){ $p->sendmessage("Not In Region"); }}