1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

help me use command from sender

Discussion in 'Plugin Help' started by FanTSM, Apr 15, 2022.

  1. FanTSM

    FanTSM Spider Jockey

    Messages:
    28
    GitHub:
    nam2k
    $this->getServer()->dispatchCommand(new \pocketmine\command\ConsoleCommandSender()
    wrong ??? pm 4
     
  2. SleepSpace9

    SleepSpace9 Slime

    Messages:
    78
    GitHub:
    sleepspace9
    PHP:
    use pocketmine\console\ConsoleCommandSender;  // the namespace changed with PM4
    ...
    PHP:
    $this->getServer()->dispatchCommand(new ConsoleCommandSender($this->getServer(), $this->getServer()->getLanguage()), "say Hello World!");
    The code above executes the command in console context (highest permissions), if you want to execute the command in the context of the player use this instead:
    PHP:
    $this->getServer()->dispatchCommand($player"me Hello World!");
     
    Last edited: Apr 15, 2022
  3. FanTSM

    FanTSM Spider Jockey

    Messages:
    28
    GitHub:
    nam2k
    oh thank you very much i have spent days but still cant find the error. Thanks a lot
     
    SleepSpace9 likes this.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.