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

[help] How to use SubCmd ?

Comments in 'Plugin Development' started by vicraft59, Aug 25, 2013.

  1. vicraft59
    Offline

    vicraft59 New Member

    Joined:
    Aug 24, 2013
    Posts:
    7
    Minecraft User:
    vicraft59
    i have a problem to use subcmd ...
    what The code to use it ?
  2. wies
    Offline

    wies Notable Member

    Joined:
    Aug 23, 2013
    Posts:
    392
    Do you mean sub commands like /command subcommand ?
  3. vicraft59
    Offline

    vicraft59 New Member

    Joined:
    Aug 24, 2013
    Posts:
    7
    Minecraft User:
    vicraft59
    Yes , exemple : /cmd subcmd
    Sorry for my poor english i'm french :(
  4. InusualZ
    Offline

    InusualZ Active Member Plugin Developer

    Joined:
    Aug 23, 2013
    Posts:
    220
    Plugins:
    1
    Minecraft User:
    Inusu4lZ
    Example:
    PHP:
       $this->api->console->register("test""[TestPlugin] Test Plugin Commands", array($this"command"));// You will put this on the init function

       
    public funtion command($cmd$params$issuer)
       {
           switch(
    $cmd)
           {
               case 
    "test":
                   
    $p2 array_shift($params); // Extract the first element of the array
                   
    if(!empty($p2) || $p2 != NULL)
                   {
                        switch(
    $p2)
                        {
                            case 
    "subcommand":
                                
    #code ...
                            
    break;
                        }
                   }
               break;
           }
       }
  5. vicraft59
    Offline

    vicraft59 New Member

    Joined:
    Aug 24, 2013
    Posts:
    7
    Minecraft User:
    vicraft59
  6. wies
    Offline

    wies Notable Member

    Joined:
    Aug 23, 2013
    Posts:
    392
    Why would you use array shift if you can do $params[0]
  7. shoghicp
    Offline

    shoghicp Staff Member PocketMine Team

    Joined:
    Aug 22, 2013
    Posts:
    436
    Plugins:
    14
    Minecraft User:
    shoghicp
    To delete that index from the array if you do implode() after that to get text
  8. inventorman101
    Offline

    inventorman101 New Member

    Joined:
    Aug 26, 2013
    Posts:
    17
    Minecraft User:
    inventorman101
    @shoghicp How do you send a message directly to a player with sendTo()?
  9. shoghicp
    Offline

    shoghicp Staff Member PocketMine Team

    Joined:
    Aug 22, 2013
    Posts:
    436
    Plugins:
    14
    Minecraft User:
    shoghicp
    Check that method arguments. You can also do that with "player object->sendChat()"
  10. InusualZ
    Offline

    InusualZ Active Member Plugin Developer

    Joined:
    Aug 23, 2013
    Posts:
    220
    Plugins:
    1
    Minecraft User:
    Inusu4lZ
    You can also make this
    PHP:
    object player->eventhandler("Blah blah blah""server.chat");
    But shoghicp solution is better.
  11. inventorman101
    Offline

    inventorman101 New Member

    Joined:
    Aug 26, 2013
    Posts:
    17
    Minecraft User:
    inventorman101
    Thanks, @shoghicp! Also why did you choose PHP instead of C++
  12. vicraft59
    Offline

    vicraft59 New Member

    Joined:
    Aug 24, 2013
    Posts:
    7
    Minecraft User:
    vicraft59
    I have other question for my 2 plugin :
    What the code for input a text ?
    Exemple : /broadcast < Your message >
  13. shoghicp
    Offline

    shoghicp Staff Member PocketMine Team

    Joined:
    Aug 22, 2013
    Posts:
    436
    Plugins:
    14
    Minecraft User:
    shoghicp
  14. vicraft59
    Offline

    vicraft59 New Member

    Joined:
    Aug 24, 2013
    Posts:
    7
    Minecraft User:
    vicraft59
  15. vicraft59
    Offline

    vicraft59 New Member

    Joined:
    Aug 24, 2013
    Posts:
    7
    Minecraft User:
    vicraft59
    I have problem , my topic for my AFKplugin is not available :/
  16. ZacHack
    Offline

    ZacHack Staff Member Sectional Moderator

    Joined:
    Aug 23, 2013
    Posts:
    326
    Plugins:
    6
    Minecraft User:
    _ZacHack_
    @vicraft59 i think he removed it because you basically copied the other afk plugin but added sub command. Sorry

Share This Page

Advertisement