Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

DelayedTask won't work.

Comments in 'Plugin Development' started by Hotshot_9930, Jul 18, 2015.

  1. Hotshot_9930
    Offline

    Hotshot_9930 Notable Member Plugin Developer

    Joined:
    May 26, 2014
    Posts:
    665
    Plugins:
    2
    Minecraft User:
    HotshotHD
    This is my task code
    PHP:
    <?php

    namespace HotshotHD;

    use 
    pocketmine\scheduler\PluginTask;
    use 
    pocketmine\plugin\Plugin;
    use 
    pocketmine\Player;
    use 
    pocketmine\entity\Effect;

    class 
    Task extends PluginTask {
      
            public function 
    __construct(Plugin $ownerPlayer $player) {
          
            
    parent::__construct($owner);
            
    $this->player $player;
        }
      
        public function 
    onRun($currentTick) {
                
    $effectid 1;
            
    $effectamp 0;
            
    $effectvis false;
            
    $effectdu 50000000000000000;
            
    $effect Effect::getEffect($effectid);
          
            
    $effect->setVisible(false);
            
    $effect->setDuration($effectdu);
            
    $effect->setAmplifier($effectamp);
        }
      
        public function 
    cancel() {
          
            
    $this->getHandler()->cancel();
        }
        }



    ?>
    And I'm trying to call on it in the PlayerDeathEvent like this
    PHP:
            $this->getServer()->getScheduler()->scheduleDelayedTask(new Task($this$player), 100);
       
    but it doesn't work. No error messages or anything. Can anyone help?
  2. Hotshot_9930
    Offline

    Hotshot_9930 Notable Member Plugin Developer

    Joined:
    May 26, 2014
    Posts:
    665
    Plugins:
    2
    Minecraft User:
    HotshotHD
    Never I mind. I figured out the problem. I forgot to add
    PHP:
    $this->player->addEffect($effect);
    My bad on that.
  3. Hotshot_9930
    Offline

    Hotshot_9930 Notable Member Plugin Developer

    Joined:
    May 26, 2014
    Posts:
    665
    Plugins:
    2
    Minecraft User:
    HotshotHD
    No I got it to work. It gives the effect 5 seconds after death.
    PEMapModder likes this.

Share This Page

Advertisement