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

Solved Enable and disable task

Discussion in 'Development' started by KHAV, Feb 2, 2018.

  1. KHAV

    KHAV Baby Zombie

    Messages:
    152
    GitHub:
    xkhhv
    Hello!

    How i can make when i type command like: /test on , the task be enable, and when i type: /test off , the task be disable?

    i hope you understand me:)
     
  2. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
    PHP:
    class MyTask extends PluginTask{
      public 
    $disable true;
      
    // your constructor code
      
    public function onRun(int $tick){
        if(
    $this->disable) return;
        
    // your normal code
      
    }
    }
    Store your task instance in a class property. When /test on, just set $this->task->disable = false, etc.
     
  3. KHAV

    KHAV Baby Zombie

    Messages:
    152
    GitHub:
    xkhhv
    i tried this but it is not working i do not know why but i think i does not understand you exactly, can you explain please or give me an example?:)
     
  4. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
    My post above is already an example...
     
    KHAV and EdwardHamHam like this.
  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.