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

Solved Commands :/

Comments in 'Plugin Development' started by Kvetinac97, Jul 8, 2015.

  1. Kvetinac97
    Offline

    Kvetinac97 Active Member Plugin Developer

    Joined:
    Nov 17, 2014
    Posts:
    276
    Plugins:
    1
    Minecraft User:
    Kvetinac97
    Hi.

    I'm developing some plugins, but I can't find how use $args. Is there any "tutorial" for using /command a b c d e f? (I can use only /command or /command a)
  2. Guillaume351
    Offline

    Guillaume351 Active Member Plugin Developer

    Joined:
    Oct 11, 2013
    Posts:
    150
    Plugins:
    1
    Minecraft User:
    Guillaume351
    $args is an array, so to get first arg do $arg[0], for arg 2 do $arg[1]...

    you can do this :
    Code:
    switch ($arg[0]){
    case "a":
    //WhatYouWantToDo
    break;
    
    case "b":
    //WantYouWantToDo
    break;
    
    }
  3. Kvetinac97
    Offline

    Kvetinac97 Active Member Plugin Developer

    Joined:
    Nov 17, 2014
    Posts:
    276
    Plugins:
    1
    Minecraft User:
    Kvetinac97
    Will It be OK?

    PHP:
    switch ($args[0]){
    case 
    "a":
    switch (
    $args[1]){
    case 
    "do":
    $sender->sendMessage("You typed /command a do!");
    break;
    }
    case 
    "b":
    $sender->sendPopup("You typed /command b!");
    break;
    }
  4. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    $args is the array of command arguments, each element for one space-separated word. Read http://php.net/arrays for more information.
    iksaku likes this.
  5. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Yes :)
    iksaku likes this.
  6. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,472
    Minecraft User:
    PrimusLV
    I suggest to use isset!
    PHP:
    if(isset($args[0])){
    switch(
    $args[0]){
    case 
    "a":
    break;
    }
    }
    Legoboy0215, PEMapModder and iksaku like this.

Share This Page

Advertisement