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

Solved get all args

Comments in 'Plugin Development' started by Palente, Nov 11, 2016.

  1. Palente
    Offline

    Palente New Member

    Joined:
    Jan 16, 2016
    Posts:
    9
    Minecraft User:
    Palente
    Hey i have seeing quickly the forum but all threads for my case is not detailed enough for me because 1. i'm french :D 2.I'm start in the development

    My case is i want to get all args for my plugin broadcaster
    the usage is /br message
    PHP:
    class broadcast extends command {
        private 
    $us "/br messag to broadcast";
        public function 
    execute(CommandSender $sender$command, array $args){
    if(
    $sender->isOp()) {
    if(
    count($args) == 0)  {
    $sender->sendMessage("WELCOME the usage is $us please to do a space do just !sp");
    }elseif (
    count($args) == 1) {
        
    $msg $args[0];
        
    $nw str_replace("!sp"" "$msg);
        
    $pal TextFormat::GREEN "[Announce] " TextFormat::WHITE $nw;
        
    $sender->getServer()->broadcastMessage($palnull);

    }else {
        
    $sender->sendMessage("WELCOME the usage is $us please to do a space do just !sp");
    }
    }else{
        return 
    false;
        }
    }
    }
    i use the str replace because i don't know how to get all args
    AND sorry for my english i'm french
  2. PocketKiller
    Offline

    PocketKiller Notable Member

    Joined:
    Jul 20, 2015
    Posts:
    741
    $args
  3. Palente
    Offline

    Palente New Member

    Joined:
    Jan 16, 2016
    Posts:
    9
    Minecraft User:
    Palente
    just $args?
    i have already do that and $args is a array
    Don't work:(
  4. PocketKiller
    Offline

    PocketKiller Notable Member

    Joined:
    Jul 20, 2015
    Posts:
    741
    PHP:
    implode(" "$args);
  5. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    You code is broken, a lot.

    PHP:
    public function __construct() {
      
    $this->setUsage("/br <...message>");
    }

    public function 
    execute(CommandSender $sender$label, array $args) {
      if(!
    $this->testPermission($sender)) return false;
      if(empty(
    $args)) return false;
      
    $sender->getServer()->broadcastMessage(TextFormat::GREEN "[Announce] " implode(" "$args));
      return 
    true;
    }
    Last edited: Nov 11, 2016
  6. Palente
    Offline

    Palente New Member

    Joined:
    Jan 16, 2016
    Posts:
    9
    Minecraft User:
    Palente
    Yes I know But For me Just they work is good I have seeing i'm starting in Development so I Do lot of error But my code work for me isn't problem :)
  7. Thunder33345
    Offline

    Thunder33345 Notable Member

    Joined:
    Apr 3, 2014
    Posts:
    755
    Minecraft User:
    Thunder33345
    yes i know you will prefer to use what you are comfortable with but sometimes it is best to make it more "proper"
    HimbeersaftLP likes this.
  8. Palente
    Offline

    Palente New Member

    Joined:
    Jan 16, 2016
    Posts:
    9
    Minecraft User:
    Palente
    Okay Thanks Yes I Know But there are lot of things were I didn't know in Pocketmine So Thanks
  9. Thunder33345
    Offline

    Thunder33345 Notable Member

    Joined:
    Apr 3, 2014
    Posts:
    755
    Minecraft User:
    Thunder33345
    No problem also our forum are moving to https://forums.pmmp.gq/
    so sooner then latter it will be abandoned
    HimbeersaftLP likes this.

Share This Page

Advertisement