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

Solved Help Cannot call constructor

Discussion in 'Development' started by TheStepKla, Sep 12, 2019.

  1. TheStepKla

    TheStepKla Silverfish

    Messages:
    20
    Code:
    [22:13:51] [Server thread/CRITICAL]: Error: "Cannot call constructor" (EXCEPTION) in "plugins/Dis10sec/src/Spawn/Task/Teleport" at line 9
    PHP:
    <?php namespace Spawn\Task;
     use 
    Spawn\Main;
     use 
    pocketmine\scheduler\Task;
     use 
    pocketmine\command\Command;
    use 
    pocketmine\command\CommandSender;
     class 
    Teleport extends Task{ public $plugin;
     public 
    $task;
     public 
    $time 11;
     public function 
    __construct(Main $plugin){ parent::__construct($plugin);
     
    $this->plugin $plugin;
     } public function 
    getPlugin(){ return $this->plugin;
     } public function 
    onRun($currentTick){ $this->time--;
     foreach(
    $this->getPlugin()->getServer()->getOnlinePlayers() as $sender){ if(isset($this->getPlugin()->task[strtolower($sender->getName())])){ $sender->sendTitle("§cจะ§6กลับ§eสปาว§aในอีก §f".$this->time."§cวินาที §6กรุณา§eอย่า§aขยับ");
     if(
    $this->time == 5){ $sender->sendTitle("§aอย่าขยับ");
     } } } if(
    $this->time == 0){ foreach($this->getPlugin()->getServer()->getOnlinePlayers() as $sender){ if(isset($this->getPlugin()->task[strtolower($sender->getName())])){
     
    $command "hub";
     
    $this->getServer()->getCommandMap()->dispatch($player$command);
     
    $sender->sendTitle("§aกลับสปาวแล้ว");
     unset(
    $this->getPlugin()->task[strtolower($sender->getName())]);
     
    $this->getPlugin()->getServer()->getScheduler()->cancelTask($this->getTaskId());
     } } } } }
    ?>
    help me please
     
  2. ZackyVN

    ZackyVN Baby Zombie

    Messages:
    150
    wow u code is really a mess
     
  3. Rim

    Rim Spider Jockey

    Messages:
    28
    GitHub:
    boomyourbang
    You don't need to call parent::__construct(), I think. All of my tasks run fine without it.
     
  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.