How to create FloatingTextParticle with multiline content? This is my code but not work. Spoiler: Code <?php namespace topkills\events; use pocketmine\math\Vector3; use pocketmine\level\particle\FloatingTextParticle; use pocketmine\scheduler\PluginTask; use topkills\EventListener; use pocketmine\utils\TextFormat; class ParticleTask extends PluginTask{ private $plugin; private $text; public function __construct(EventListener $plugin) { $this->plugin = $plugin; parent::__construct($plugin); $this->text = new FloatingTextParticle(new Vector3(8, 15, -15), "", "§eTop Killers"); } public function onRun($currentTick) { $data = $this->plugin->getTopList(); $i = 1; foreach ($data as $player => $points) { $level = $this->plugin->getServer()->getLevelByName("world"); $this->text-> $this->text->setText(TextFormat::GREEN . "[" . $i . "] " . TextFormat::YELLOW . ucfirst($player) . " : " . TextFormat::RED . TextFormat::BOLD . $points); $i++; $level->addParticle($this->text); } }
This is my code PHP: <?phpnamespace topkills\events;use pocketmine\math\Vector3;use pocketmine\level\particle\FloatingTextParticle;use pocketmine\scheduler\PluginTask;use topkills\EventListener;use pocketmine\utils\TextFormat;class ParticleTask extends PluginTask{private $plugin;private $text;public function __construct(EventListener $plugin){$this->plugin = $plugin;parent::__construct($plugin);$this->text = new FloatingTextParticle(new Vector3(8, 15, -15), "", "§eTop Killers");}public function onRun($currentTick){$data = $this->plugin->getTopList();$i = 1;foreach ($data as $player => $points) {$level = $this->plugin->getServer()->getLevelByName("world"); $this->text->setText(TextFormat::GREEN . "[" . $i . "] " . TextFormat::YELLOW . ucfirst($player) . " : " . TextFormat::RED . TextFormat::BOLD . $points);$i++;$level->addParticle($this->text);}} [
PHP: $this->text->setText(TextFormat::GREEN . "[" . $i . "] " . TextFormat::YELLOW . ucfirst($player) . " : " . TextFormat::RED . TextFormat::BOLD . $points . "\n");
This would create a new particle for every line. Better append the lines and move $level->addParticle() out of the loop.