PHP: public function addParticle($text){ foreach($this->getServer()->getLevelByName("world")->getPlayers() as $p){ $x = -797; $y = 6; $z = -1093; if($this->i == 0){ $this->i++; $this->particle = new FloatingTextParticle(new Vector3($x, $y, $z), $text, "HungryGames"); $p->getLevel()->addParticle($this->particle); } else { $this->particle->setInvisible(true); $p->getLevel()->addParticle($this->particle); $this->i = 0; } } } It works for one player. I try to delete all particles. When join second player. Result:
When i try: PHP: public function addParticle($text){ foreach($this->getServer()->getLevelByName("world")->getPlayers() as $p){ $x = -797; $y = 6; $z = -1093; if($this->i == 0){ $this->i++; $this->particle = new FloatingTextParticle(new Vector3($x, $y, $z), $text, "HungryGames"); $p->getLevel()->addParticle($this->particle,array($p)); } else { $this->particle->setInvisible(true); $p->getLevel()->addParticle($this->particle,array($p)); $this->i = 0; } } } When join second player(result):
If you're experiencing overlapping issues, use PHP: Level::addParticle($particle, [$player]); So when a player joins, add the particle and use the player from that event in the second parameter of the addParticle method.
Errors Deprecated: Non-static method pocketmine\level\Level::addParticle() should not be called statically in /root/Genisys/plugins/sg/src/load/mclass.php on line 106 [05:02:08] [Server thread/CRITICAL]: Could not execute task load\Task: Argument 2 passed to pocketmine\level\Level::addParticle() must be of the type array, object given, called in /root/Genisys/plugins/sg/src/load/mclass.php on line 106 [05:02:08] [Server thread/CRITICAL]: TypeError: "Argument 2 passed to pocketmine\level\Level::addParticle() must be of the type array, object given, called in /root/Genisys/plugins/sg/src/load/mclass.php on line 106" (EXCEPTION) in "/src/pocketmine/level/Level" at line 516 p
Level::addParticle() is a nonstatic method. Lambo just told you the function. You should use it upon a level object.
I updated my code to support the array type. Weird that they use that, because in the code of the method they even check if it's an array or just a player. Also, it's a non-static method. Meaning that you have to call it on a Level object.