Help me?

Discussion in 'Help' started by Mochi, Mar 14, 2020.

  1. Mochi

    Mochi Spider Jockey

    Messages:
    44
    how to add an online player, name, but does not appear to appear in floating text

    This my task :
    PHP:
    <?php

    namespace moch;

    use 
    onebone\economyapi\EconomyAPI;
    use 
    pocketmine\level\particle\FloatingTextParticle;
    use 
    pocketmine\math\Vector3;
    use 
    pocketmine\Player;
    use 
    pocketmine\scheduler\Task;
    use 
    moch\Main;

    class 
    statsTask extends Task {

         private 
    $plugin;

         public function 
    __construct(Main $plugin) {
            
    $this->plugin $plugin;
            
        }

         public function 
    onRun(int $currentTick) {
              
    $online   count($this->plugin->getServer()->getOnlinePlayers());

              
    $title    "§fWelcome To Test Server";
              
              
    $message  "§bOnline Players: §c{$online}\n";
              
              
    $message  "§bServer Version : ALPHA 1.2.0\n";

              if(isset(
    $this->pVar)){ //Will probably throw an error else
                  
    $level $this->plugin->getServer()->getLevelByName("Test");   //Put level name here
                  
    $this->pVar->setInvisible();
                  
    $level->addParticle($this->pVar$level->getPlayers());
            }
            
    $p = new FloatingTextParticle(new Vector3(26866268), $message$title);
            
    $level $this->plugin->getServer()->getLevelByName("Test");   //Put level name here
            
    $level->addParticle($p$level->getPlayers());
         }
    }
     

    Attached Files:

  2. Mr174

    Mr174 Baby Zombie

    Messages:
    186
    GitHub:
    mr174
    You are overwriting the online message
     
  3. Mochi

    Mochi Spider Jockey

    Messages:
    44
    Can you help me?
     
  4. Invy55

    Invy55 Witch

    Messages:
    52
    GitHub:
    invy55
    try this (warning not tested code)
    PHP:
    <?php

    namespace moch;

    use 
    onebone\economyapi\EconomyAPI;
    use 
    pocketmine\level\particle\FloatingTextParticle;
    use 
    pocketmine\math\Vector3;
    use 
    pocketmine\Player;
    use 
    pocketmine\scheduler\Task;
    use 
    moch\Main;

    class 
    statsTask extends Task {

         private 
    $plugin;

         public function 
    __construct(Main $plugin) {
            
    $this->plugin $plugin;
            
        }

         public function 
    onRun(int $currentTick) {
              
    $online   count($this->plugin->getServer()->getOnlinePlayers());

              
    $title    "§fWelcome To Test Server";
              
              
    $message  "§bOnline Players: §c{$online}\n";
              
              
    $message  .= "§bServer Version : ALPHA 1.2.0\n";

              if(isset(
    $this->pVar)){ //Will probably throw an error else
                  
    $level $this->plugin->getServer()->getLevelByName("Test");   //Put level name here
                  
    $this->pVar->setInvisible();
                  
    $level->addParticle($this->pVar$level->getPlayers());
            }
            
    $p = new FloatingTextParticle(new Vector3(26866268), $message$title);
            
    $level $this->plugin->getServer()->getLevelByName("Test");   //Put level name here
            
    $level->addParticle($p$level->getPlayers());
         }
    }
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.