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

Erros with task

Discussion in 'Facepalm' started by DanielYTK, Jun 30, 2017.

  1. DanielYTK

    DanielYTK Zombie

    Messages:
    227
    I got this error when I try to activate my task:
    Code:
    [Server thread/CRITICAL]: pocketmine\utils\PluginException: "Invalid owner of PluginTask DanielYTK\CA" (EXCEPTION) in "/src/pocketmine/scheduler/ServerScheduler" at line 190
    
    Code to activate my task:
    (ps: it's in the main of file)
    PHP:
    $this->getServer()->getScheduler()->scheduleRepeatingTask(new CB($this$player$inv), 5);
     
  2. RoyalMCPE

    RoyalMCPE Slime

    Messages:
    87
    Show us the task file.
     
  3. DanielYTK

    DanielYTK Zombie

    Messages:
    227
    PHP:
    <?php
    namespace DanielYTK;

    use 
    DanielYTK\main;
    use 
    pocketmine\scheduler\PluginTask;
    use 
    pocketmine\Player;
    use 
    pocketmine\item\Item;
    use 
    pocketmine\level\Level;
    use 
    pocketmine\block\Block;
    use 
    pocketmine\math\Vector3;

    class 
    CB extends PluginTask{
        public 
    $plugin;
        public 
    $player;
        public 
    $inv;
        public 
    $type;
        public 
    $time;
        public function 
    __construct($plugin$player$inv){
            
    $this->plugin $plugin;
            
    $this->player $player;
            
    $this->inv $inv;
            
    $this->time 40;
        }
        public function 
    getPlugin(){
            return 
    $this->plugin;
        }
        public function 
    onRun($ticks){
            if(
    $this->time === 0){
                
    $this->plugin->getServer()->getScheduler()->cancelTask($this->getTaskId());
                
    $this->inv->close($this->player);
                
    $this->player->getLevel()->setBlock(new Vector3($this->player->getX(), $this->player->getY()-2$this->player->getZ()), Block::get(Block::AIR));
                
    $this->plugin->giveReward($this->player"basica");
            }
            
    $itens = [
                
    Item::get(5708),
                
    Item::get(4208),
                
    Item::get(27601),
                
    Item::get(27701),
                
    Item::get(27801),
                
    Item::get(27901),
                
    Item::get(31001),
                
    Item::get(31101),
                
    Item::get(31201),
                
    Item::get(31301),
                
    Item::get(12011)->setCustomName("§r§6Caixa Avançada"),
            ];
            
    $this->inv->setItem(10$itens[mt_rand(1,10)]);
               
        }
    }
     
  4. RoyalMCPE

    RoyalMCPE Slime

    Messages:
    87
    PHP:
    <?php
    namespace DanielYTK;

    use 
    DanielYTK\main;
    use 
    pocketmine\scheduler\PluginTask;
    use 
    pocketmine\Player;
    use 
    pocketmine\item\Item;
    use 
    pocketmine\level\Level;
    use 
    pocketmine\block\Block;
    use 
    pocketmine\math\Vector3;

    class 
    CB extends PluginTask{
        public 
    $plugin;
        public 
    $player;
        public 
    $inv;
        public 
    $type;
        public 
    $time;
        public function 
    __construct(main $plugin$player$inv){
            
    $this->plugin $plugin;
            
    $this->player $player;
            
    $this->inv $inv;
            
    $this->time 40;
        }
        public function 
    getPlugin(){
            return 
    $this->plugin;
        }
        public function 
    onRun($ticks){
            if(
    $this->time === 0){
                
    $this->plugin->getServer()->getScheduler()->cancelTask($this->getTaskId());
                
    $this->inv->close($this->player);
                
    $this->player->getLevel()->setBlock(new Vector3($this->player->getX(), $this->player->getY()-2$this->player->getZ()), Block::get(Block::AIR));
                
    $this->plugin->giveReward($this->player"basica");
            }
            
    $itens = [
                
    Item::get(5708),
                
    Item::get(4208),
                
    Item::get(27601),
                
    Item::get(27701),
                
    Item::get(27801),
                
    Item::get(27901),
                
    Item::get(31001),
                
    Item::get(31101),
                
    Item::get(31201),
                
    Item::get(31301),
                
    Item::get(12011)->setCustomName("§r§6Caixa Avançada"),
            ];
            
    $this->inv->setItem(10$itens[mt_rand(1,10)]);
               
        }
    }
     
  5. DanielYTK

    DanielYTK Zombie

    Messages:
    227
    same error.
     
  6. DanielYTK

    DanielYTK Zombie

    Messages:
    227
    Solved, I used only this:
    PHP:
    parent::__construct($plugin);
     
  7. Teamblocket

    Teamblocket Zombie

    Messages:
    301
    GitHub:
    teamblocket
    :facepalm:
     
  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.