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

Command Help

Discussion in 'Development' started by Zoom601, Feb 9, 2018.

  1. Zoom601

    Zoom601 Silverfish

    Messages:
    21
    Hello PMMP Forum!

    I want to make a command that when you send it for the first time make thing and when i send it for the second time make thing else, and when i send it for the third one its back like you send it for the first time, So how i can make it?

    i am sorry if my english is bad :)
     
  2. Flavius12

    Flavius12 Spider Jockey

    Messages:
    32
    GitHub:
    flavius12
    PHP:
    <?php

    use pocketmine\command\Command;
    use 
    pocketmine\command\CommandExecutor;
    use 
    pocketmine\command\CommandSender;
    use 
    pocketmine\plugin\PluginBase;

    class 
    Commands extends PluginBase implements CommandExecutor {

        private 
    $plugin;

        private 
    $status false;  

        public function 
    __construct(YourPlugin $plugin){
            
    $this->plugin $plugin;
        }
     
        public function 
    onCommand(CommandSender $senderCommand $cmd$label, array $args) : bool {
             if(
    $this->status){
                 
    //Do the first thing here...
             
    }else{
                 
    //Do the other thing here...
             
    }
             
    $this->status = !$this->status;
             return 
    true;
        }
    }
     
    Last edited: Feb 9, 2018
  3. DaPigGuy

    DaPigGuy Slime

    Messages:
    86
    GitHub:
    DaPigGuy
    You mean $this->status? $status is not defined
     
  4. Flavius12

    Flavius12 Spider Jockey

    Messages:
    32
    GitHub:
    flavius12
    Yes, you're right. I was sleeping :facepalm:
     
  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.