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

Run command from another command

Comments in 'Plugin Development' started by IcePL, Apr 2, 2016.

  1. IcePL
    Offline

    IcePL New Member

    Joined:
    Feb 16, 2016
    Posts:
    73
    Minecraft User:
    IcePL
    Hi guys:)
    I need help, im make a plugin for my server like this:
    Player write in chat /test and this command give diamond to player and run command like /give or /say.
    But im have a problem, this is the code:
    PHP:
                case "eq1e":
                  if(
    $sender->getInventory()->contains(Item::get(1001))){
                     
    $sender->getInventory()->removeItem(Item::get(1001));
                     
    $player $this->getServer()->getPlayer();
                     
    $this->getServer()->dispatchCommand($player,"say hello");
                   
    $sender->sendMessage("§aWitaj dziekuje za lave.");
                   
    $sender->sendMessage("§aOd teraz masz nieskonczony zapas mieczy.");
                   
    $sender->sendMessage("§aMozesz je odbierac w magazynie.");
        }
        else{
           
    $sender->sendMessage("Nie masz lavy!");
        }
                   return 
    true;
    And when i run the command, it display me " Unknow command"
  2. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    probably say command doesn't exist
  3. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    If there is a way to do it directly, don't do it indirectly by running command as a player.
    applqpak likes this.
  4. KubixQ
    Offline

    KubixQ Active Member

    Joined:
    Sep 13, 2015
    Posts:
    85
    Minecraft User:
    KubixQ
  5. Vaivez66
    Offline

    Vaivez66 Notable Member Plugin Developer

    Joined:
    Jun 10, 2015
    Posts:
    402
    Plugins:
    2
    Ummm, what's the point by doin' $this->getServer()->getPlayer() without any argument inside?
    https://github.com/PocketMine/PocketMine-MP/blob/master/src/pocketmine/Server.php#L827
    PEMapModder and applqpak like this.

Share This Page

Advertisement