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

How do i use command arguments

Comments in 'Plugin Development' started by Renzo, Jun 7, 2014.

  1. Renzo
    Offline

    Renzo Active Member

    Joined:
    Mar 12, 2014
    Posts:
    96
    Minecraft User:
    Renzo_4
    How do you use command arguments?
  2. Lambo
    Offline

    Lambo Notable Member Plugin Developer

    Joined:
    Sep 14, 2013
    Posts:
    435
    Plugins:
    4
    Minecraft User:
    Lambo
    Use use $args[arg]
    Example:
    PHP:
    public function cmd($cmd$args$issuer){
       if(
    $cmd=="broadcaster"){
          if(isset(
    $args[0])){
             if(
    $args[0]=="add"){
                
    $msg=null;
                for(
    $i=1;$i<count($args);$i++){
                   
    $msg .= $args[$i]." ";
                }
                
    $issuer->sendChat("Message ".$msg." has been added!");
             }else 
    $issuer->sendChat("Usage: /broadcaster add <msg>"):
          }else 
    $issuer->sendChat("Usage: /broadcaster add <msg>");
       }
    }
    Last edited: Jun 7, 2014
    LDX likes this.

Share This Page

Advertisement