1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Titles and Sound not working on delay task

Discussion in 'Development' started by rektpixel, Oct 12, 2017.

  1. rektpixel

    rektpixel Baby Zombie

    Messages:
    186
    When I put a title message and sound on a delay task (from join) it does not display and it shows no errors, why is this?? :eek:
    PHP:
    <?php
    namespace basprohop\JoinEvent;
    use 
    pocketmine\Player;
    use 
    pocketmine\Server;
    use 
    pocketmine\utils\TextFormat;
    use 
    pocketmine\scheduler\PluginTask;
    use 
    basprohop\CombinedSlots;
    use 
    pocketmine\math\Vector3;
    use 
    pocketmine\level\sound\LaunchSound;
    class 
    ShowTask extends PluginTask {
        
    /** @var Player */
        
    private $player;
       
        public function 
    __construct($pluginPlayer $player) {
        
    parent::__construct($plugin);
        
    $this->player $player;
        }

        public function 
    onRun($currentTick) {
            
    $this->player->addTitle("#bla#nk#"""58020);
            
    $level $this->player->getLevel();
            
    $level->addSound(new LaunchSound(new Vector3(4945, -890)));
            return 
    true;
        }
    }
     
  2. Levi

    Levi Skeleton

    Messages:
    955
    GitHub:
    captainleviftw
    add pocketmine\level\Level?
    and what is $plugin on __construct?
     
  3. jasonwynn10

    jasonwynn10 Moderator Poggit Reviewer

    Messages:
    1,489
    GitHub:
    jasonwynn10
    How long is the task delayed?
    Why is your constructor not compatible with PluginTask ?
    Why are you passing Player objects to a task?
    Are you certain you scheduled the task properly?
     
  4. SalmonDE

    SalmonDE Zombie Pigman

    Messages:
    739
    GitHub:
    SalmonDE
    PHP:
    public function onRun(int $currentTick){}
    Add int before $currentTick
     
  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.