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

Why it does not work?

Discussion in 'Plugin Help' started by Pqoster, Aug 28, 2020.

  1. Pqoster

    Pqoster Spider Jockey

    Messages:
    25
    Why it does not work?
    when the player executes "/ cps on" starts the task
    when you run "/ cps off" it cancels the task
    Can someone help me please?

    - Sorry for my bad English
    PHP:
          public $cps false;
                     
    // MAIN
                  
    case "cps":
                if(!isset(
    $args[0])){
                    if (
    $sender instanceof Player) {
        
    $sender->sendMessage("§e§lUSO: §r§e/cps§7 <on/off>");
          
             } else {
    $sender->sendMessage("§cUse o comando dentro do jogo!");
    }
             } else {

                    if(
    $args[0] == "on"){
    $this->getScheduler()->scheduleRepeatingTask(new BMsg($this$sender), 1);
                        
    $sender->sendMessage("§e§lMOD: §r§eCPS ativado com sucesso!");

                } elseif (
    $args[0] == "off"){
                        
    $sender->sendMessage("§e§lMOD: §r§eCPS desligado com sucesso!");     
                     
    $this->cps false;
          }           
        } 
    PHP:
     // TASK
        
    public function onRun(int $currentTick)
        {    
            
    $cps $this->plugin->getClicks($this->player);   
             
    $this->player->sendTip("§eCPS:§7 {$cps}");           
         if(
    $this->plugin->cps false){
        
    $this->plugin->getScheduler()->cancelTask($this->getTaskId());
    }
    }
    }
     
  2. MinekCz

    MinekCz Spider Jockey

    Messages:
    29
    In if you used one =. You must use == (in your task)
     
    Pqoster likes 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.