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

what error my code ? plz help me

Comments in 'Plugin Development' started by PmServer, Mar 31, 2016.

Thread Status:
Not open for further replies.
  1. PmServer
    Offline

    PmServer New Member

    Joined:
    May 7, 2015
    Posts:
    53
    Minecraft User:
    PmServer
    what error ?
    Code:
    [22:49:47] [Server thread/CRITICAL]: Could not execute task Time\Countdown: Call to a member function getTaskId() on null
    [22:49:47] [Server thread/CRITICAL]: Error: "Call to a member function getTaskId() on null" (EXCEPTION) in "/Tlp/src/Time/Main" at line 30
    
    PHP:
    <?php

    namespace Time;

    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\event\Listener;
    use 
    pocketmine\scheduler\PluginTask;
    use 
    pocketmine\plugin\Plugin;

    class 
    Main extends PluginBase implements Listener {
        public function 
    onEnable() {
            
    $this->getServer()->getPluginManager()->registerEvents($this$this);
            
    $this->getServer ()->getScheduler ()->scheduleRepeatingTask( new Countdown $this ), 50 );
        }
    }
    class 
    Countdown extends PluginTask {
        public 
    $sec 10;
        public function 
    __construct(Main $plugin) {
            
    $this->plugin $plugin;
            
    parent::__construct($plugin);
           
        }

        public function 
    onRun($tick) {
            
    $this->sec--;
                foreach(
    $this->plugin->getServer()->getOnlinePlayers() as $players) {    
                    
    $players->sendPopup("[Game] Start in ".$this->sec." second(s) !");
                       if(
    $this->sec === 0){
                        
    $players->sendPopup("[lGame] Started !! Gogo !");
    $this->plugin->getServer()->getScheduler()->cancelTask($this->getHandler()->getTaskId());


              
    }}}}
  2. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    Mind reading API Docs?
    applqpak likes this.
  3. PmServer
    Offline

    PmServer New Member

    Joined:
    May 7, 2015
    Posts:
    53
    Minecraft User:
    PmServer
    what ?? i did not understand what you say
  4. PmServer
    Offline

    PmServer New Member

    Joined:
    May 7, 2015
    Posts:
    53
    Minecraft User:
    PmServer
  5. Gamecrafter
    Offline

    Gamecrafter

    Joined:
    Nov 20, 2014
    Posts:
    978
    Plugins:
    9
    If you don't even understand what reading the PocketMine API documentation means, then I suppose plugin development isn't right for you. Change $this->getHandler()->getTaskId() to $this->getTaskId(). And stop it with the spam, people don't reply instantly.
    applqpak and Primus like this.
Thread Status:
Not open for further replies.

Share This Page

Advertisement