setInvisible() is doesn't work in my plugin, why ? thank you in advance PHP: <?phpnamespace text;use pocketmine\plugin\PluginBase;use pocketmine\Server;use pocketmine\event\player\PlayerJoinEvent;use pocketmine\event\player\PlayerQuitEvent;use pocketmine\level\particle\FloatingTextParticle;use pocketmine\level\particle\Particle;use pocketmine\event\Listener;use pocketmine\Player;use pocketmine\level\Position;use pocketmine\level\Level;use pocketmine\math\Vector3;use pocketmine\utils\Config;use pocketmine\utils\TextFormat as TF;class Main extends PluginBase implements Listener{ public $Main; public $text; public function onEnable(){ $this->saveDefaultConfig(); $this->getResource("config.yml"); $this->getLogger()->info(TF::GREEN."Text loaded by SkySeven!"); $this->getServer()->getPluginManager()->registerEvents($this, $this); $this->spawnText(); } public function onDisable(){ } public function onJoin(PlayerJoinEvent $event){ $particle = $this->text; $this->respawnText($particle); } public function onQuit(PlayerQuitEvent $event){ $particle = $this->text; $this->respawnText($particle); } public function spawnText(){ $online = count(Server::getInstance()->getOnlinePlayers()); $r = TF::RESET."\n"; $x = $this->getConfig()->get("SpawnX"); $y = $this->getConfig()->get("SpawnY"); $z = $this->getConfig()->get("SpawnZ"); $level = $this->getServer()->getLevelByName($this->getConfig()->get("Level")); $line1 = $this->getConfig()->get("Line1"); $line2 = $this->getConfig()->get("Line2"); $line3 = $this->getConfig()->get("Line3"); $line4 = $this->getConfig()->get("Line4"); $line5 = $this->getConfig()->get("Line5"); $line6 = $this->getConfig()->get("Line6"); $lines = $line1 . $r . $line2 . $r . $line3 . $r. $line4 . $r . $line5 . $r . $line6; $lines = str_replace("{ONLINE}", $online, $lines); $this->text = new FloatingTextParticle(new Vector3($x, $y, $z), $lines); $level->addParticle($this->text); } public function respawnText($particle){ $particle->setInvisible(true); $this->spawnText(); }}
there a [php][/php] BTW even tho it is not necessary i just wish to point it out but i am guessing you need to actually respawn to all to make it invisible and visible
What is this PHP: $online = count(Server::getInstance()->getOnlinePlayers()); You may use that PHP: foreach($this->getServer()->getOnlinePlayers() as $online) {} And use PHP: $level->addParticle($this->text, $online);
Use getNested() good method ... the probleme its Is that you disable the particle you put it in '$particle->setInvisible(true);' = your particle its not visible :/
Everytime you make changes to a particle you need to add it again so it should be PHP: public function respawnText($particle){ $particle->setInvisible(true); $this->getServer()->getLevelByName($this->getConfig()->get("Level"))->addParticle($particle); } also you should not be creating a new particle everytime, just create it once in onEnable will do