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

Task instance error

Comments in 'Plugin Development' started by Artide, Sep 11, 2015.

  1. Artide
    Offline

    Artide Active Member

    Joined:
    Apr 20, 2015
    Posts:
    214
    Minecraft User:
    Artide5
    I'm getting an error with schedule task.
    [22:32:50] [Server thread/NOTICE]: InvalidArgumentException: "Argument 1 passed to pocketmine\scheduler\ServerScheduler::scheduleRepeatingTask() must be an instance of pocketmine\scheduler\Task, instance of HG\Timer given, called in C:\Users\Jesus\Downloads\PocketMine-MP\plugins\HG\src\HG\Main.php on line 22 and defined" (E_RECOVERABLE_ERROR) in "/src/pocketmine/scheduler/ServerScheduler" at line 119
  2. Falk
    Offline

    Falk Staff Member Global Moderator

    Joined:
    Sep 2, 2013
    Posts:
    1,706
    Plugins:
    22
    Minecraft User:
    Falkirknh
    Your Timer class should extend PluginTask.
  3. Artide
    Offline

    Artide Active Member

    Joined:
    Apr 20, 2015
    Posts:
    214
    Minecraft User:
    Artide5
    Ok it worked thanks :D, but how do I send logger or something to test if it works because I keep getting error message.
    PHP:
        public function onRun($tick){

            
    $this->plug->secs--;

            if(
    $this->plug->secs === 0){

                
    $this->getLogger()->info("it works!");

                
    $this->plug->secs 5;

            }
        }
    Fatal error: Call to undefined method HG\Timer::getLogger() in C:\Users\Jesus\Downloads\PocketMine-MP\plugins\HG\src\HG\Timer.php on line 25
  4. Gamecrafter
    Offline

    Gamecrafter

    Joined:
    Nov 20, 2014
    Posts:
    978
    Plugins:
    9
    Use $this->plugin->getLogger()->info("it works!");
    PEMapModder and Artide like this.
  5. Artide
    Offline

    Artide Active Member

    Joined:
    Apr 20, 2015
    Posts:
    214
    Minecraft User:
    Artide5
    Finally something useful. xD
    PEMapModder likes this.
  6. Gamecrafter
    Offline

    Gamecrafter

    Joined:
    Nov 20, 2014
    Posts:
    978
    Plugins:
    9
    I just get irritated sometimes with all the dumb questions. XD

Share This Page

Advertisement