Hi there! i'm trying to make a Particle effects plugin for my server. The VIP have some particles when they walk but i want that to desactive it if they want, but i cant figure it out how could i do it with a command. So for example if the player execute the command /particle the plugin give him the particles, but if he execute /particlesno the particles dissapear. For now i have this code. Thanks! PD: I can add this in an UI Core that i have. But first i want to know how i could disactive that particles. PHP: public function particulas(PlayerMoveEvent $event) { $player = $event->getPlayer(); $pos = $player->getPosition(); if($event->getPlayer()->hasPermission("tornadus.particulas.lobby") == true) { $red = new DustParticle($pos->add(0, 2.5), 252, 17, 17); $orange = new DustParticle($pos->add(0, 2.1), 252, 135, 17); $yellow = new DustParticle($pos->add(0, 1.7), 252, 252, 17); $green = new DustParticle($pos->add(0, 1.3), 17, 252, 17); $lblue = new DustParticle($pos->add(0, 0.9), 94, 94, 252); $dblue = new DustParticle($pos->add(0, 0.5), 17, 17, 252); foreach ([$red, $orange, $yellow, $green, $lblue, $dblue] as $particle) { $pos->getLevel()->addParticle($particle); } } }
You could either save the player who have it disabled (or enabled) in an array or remove the permission from them when they use the command.
Make a class property. PHP: private $particlesEnabled = []; When the player executes the command, the following code will toggle the particles: PHP: $name = $sender->getName();if (!isset($this->particlesEnabled[$name]) { $this->particlesEnabled[$name] = false;}$this->particlesEnabled[$name] = !$this->particlesEnabled[$name]; In your particle function: PHP: if (isset($this->particlesEnabled[$name]) && $this->particlesEnabled[$name]) { // do particle stuff}