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

dispatch command in Pocketmine-MP

Discussion in 'Help' started by Kkora, Oct 18, 2018.

  1. Kkora

    Kkora Baby Zombie

    Messages:
    189
    GitHub:
    shisui203
    Hey everyone, will this code work?

    PHP:
    case "hellminer":
              
    $p $this->getServer()->getPlayer($sender->getName());
              
    $money $this->getServer()->getPluginManager()->getPlugin("EconomyAPI")->myMoney($sender);
               if(
    $money 5000) {
                
    $sender->sendMessage(TF::RED "Insufficient Money!");
               }
               else {
                
    $this->getServer()->getPluginManager()->getPlugin("EconomyAPI")->reduceMoney($sender->getName(), 5000);
                                                
    $this->getServer()->dispatchCommand(new ConsoleCommandSender(),'setuperm '.$p.' sbkit.hminer');
               
    $sender->sendMessage(TF::RED "Successfully bought this kit!!");
               }
     
  2. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    You shouldn't rely on anyone here telling you whether your code will work or not, you should test the code yourself.
    That was fine previously but ever since Xbox Live integration, players are allowed to have spaces in their username, which can break the command or create a loophole.
    Read: Players with space in their username!
     
    Last edited: Oct 18, 2018
  3. Kkora

    Kkora Baby Zombie

    Messages:
    189
    GitHub:
    shisui203
    I've tried and it not work!
    The Economy was fine but the dispatch command not work. My player said that they lost their Money but they didn't get their Rank.
     
  4. Kkora

    Kkora Baby Zombie

    Messages:
    189
    GitHub:
    shisui203
    It doesn't work!
    My players said that they lost their money but they didn't get their rank.
    That why I need everyone to check this code.
     
  5. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
    inb4 semicolons are allowed in commands and we run into command line injection.
     
    Muqsit likes this.
  6. jasonwynn10

    jasonwynn10 Moderator Poggit Reviewer

    Messages:
    1,489
    GitHub:
    jasonwynn10
    I don't know, does it?
     
  7. Kkora

    Kkora Baby Zombie

    Messages:
    189
    GitHub:
    shisui203
    This is my Second time I made an plugin :)
     
  8. Kkora

    Kkora Baby Zombie

    Messages:
    189
    GitHub:
    shisui203
    And I tried for 16 times, it just say:" An error occured...".
    My players wanted to buy that rank :)
     
  9. AlexPads

    AlexPads Spider Jockey

    Messages:
    27
    GitHub:
    alexpads
    @Kkora Idk if this got solved but have you tried making sure that :

    use pocketmine\command\Command;
    use pocketmine\command\CommandSender;
    use pocketmine\command\ConsoleCommandSender;

    were all in the File? :)
     
  10. MalakasPlayzMCPE

    MalakasPlayzMCPE Zombie Pigman

    Messages:
    667
    PHP:
    $this->getServer()->dispatchCommand(new ConsoleCommandSender(),'setuperm "'.$p->getName().'" sbkit.hminer');
     
  11. Kkora

    Kkora Baby Zombie

    Messages:
    189
    GitHub:
    shisui203
    yes, they are in my file now but still not work!
     
  12. Thunder33345

    Thunder33345 Moderator Staff Member

    Messages:
    2,137
    GitHub:
    Thunder33345
    you are NOT suppose to use dispatch cmd if there's an api
    you should use pureperm api like wise on how you dont dispatch reduce money command
     
  13. Kkora

    Kkora Baby Zombie

    Messages:
    189
    GitHub:
    shisui203
    how? Can you give me an example?
     
  14. MalakasPlayzMCPE

    MalakasPlayzMCPE Zombie Pigman

    Messages:
    667
    I fixed his error in the code, not the code.
     
  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.