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

How to make a /msg Command

Comments in 'Plugin Development' started by TheBison_, Dec 29, 2015.

Thread Status:
Not open for further replies.
  1. TheBison_
    Offline

    TheBison_ New Member

    Joined:
    Mar 31, 2014
    Posts:
    46
    Minecraft User:
    TheBisonXD_
    Hello Guys!
    Could someone give me an example how to make the /msg command?

    /msg <NAME> <MESSAGE>

    - ty
  2. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    The /msg command already exists in PocketMine, as an alias to /tell.
    iDirtPlayzMC likes this.
  3. TheBison_
    Offline

    TheBison_ New Member

    Joined:
    Mar 31, 2014
    Posts:
    46
    Minecraft User:
    TheBisonXD_
    Okay but how can i overwrite it?
  4. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    I'm in a hurry right now, but have a look at EssentialsPE's source code.
  5. TheBison_
    Offline

    TheBison_ New Member

    Joined:
    Mar 31, 2014
    Posts:
    46
    Minecraft User:
    TheBisonXD_
    Okey i will see. Thanks for your Help sir!
  6. XFuryMCPE
    Offline

    XFuryMCPE Active Member Plugin Developer

    Joined:
    Jun 19, 2015
    Posts:
    137
    Plugins:
    2
    Minecraft User:
    XFuriousMC
    And he was never seen again.
  7. XFuryMCPE
    Offline

    XFuryMCPE Active Member Plugin Developer

    Joined:
    Jun 19, 2015
    Posts:
    137
    Plugins:
    2
    Minecraft User:
    XFuriousMC
    PHP:
    public function onCommand(CommandSender $sender$cmd, array $args){

    if(
    strtolower($cmd) == "message"){
      
    $p $this->getPlayer($args[0]);
      if(!
    $p instanceof Player){
       
    $sender->sendMessage("Player not found!");
      }
      else{
       
    $sender->sendMessage("[Me" -> ".$args[0]."".$args[1]);
       
    $p->sendMessage("[".$sender->getName()." -> Me".$args[1]);
      }
    }
      
    Uh, I'm looking this over, I probably messed up somewhere. But that is sorta how you do it.
    applqpak likes this.
  8. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    This will not work with /msg because PocketMine already registered the /msg alias, you have to override it or unregister it to work.
    Better "was never seen again" than replying wrongly.
    Last edited: Jan 15, 2016
    Vaivez66 likes this.
  9. XFuryMCPE
    Offline

    XFuryMCPE Active Member Plugin Developer

    Joined:
    Jun 19, 2015
    Posts:
    137
    Plugins:
    2
    Minecraft User:
    XFuriousMC
    And that's why it doesn't say "msg". It says "message". -_-, was that the only 'wrong' thing ?
    applqpak and AndrewBit like this.
  10. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    If it is "message" instead of "msg", it would be as simple as adding a command. We have plenty of tutorials that teach that. Why need to create this thread? We are talking about how to overwrite a command.
    applqpak likes this.
  11. AndrewBit
    Offline

    AndrewBit Notable Member

    Joined:
    Jun 18, 2015
    Posts:
    435
    Minecraft User:
    AndrewBit4
    I don't remember where I saw setExecutor(), I think that it can be enought...
    PHP:
    $this->getCommand("msg")->setExecutor(new CommandExecutorClass());
  12. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    You can only setExecutor for plugin commands.
    applqpak likes this.
  13. XFuryMCPE
    Offline

    XFuryMCPE Active Member Plugin Developer

    Joined:
    Jun 19, 2015
    Posts:
    137
    Plugins:
    2
    Minecraft User:
    XFuriousMC
    Gotta be so rude about it? I was just trying to help. What I wasn't doing was asking for your drama. The thread is named "How to make a /msg command", not named "How to overwrite a command". Sorry if I'm not answering correctly, but at least I tried. All I see you doing is correcting other people's mistakes. Also,

    You said this 2 weeks ago, and just completely left this guy waiting. Maybe you should've checked the EssentialsPE source and helped @TheBison_ like you said you would, instead of correcting me while trying to help. That would be the better choice I think :D K? Learn some manners, and respect. Boi
    applqpak likes this.
  14. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    If this thread is about how to create a command, it has no value of existence. By the way, simply adding a handler in onCommand does not work if you don't register it.
    You may already have noticed, but
    Last edited: Jan 16, 2016
    applqpak likes this.
  15. XFuryMCPE
    Offline

    XFuryMCPE Active Member Plugin Developer

    Joined:
    Jun 19, 2015
    Posts:
    137
    Plugins:
    2
    Minecraft User:
    XFuriousMC
    Lmao still going to correct me? You're like a wild Pokemon with only 3 moves... "BackTalk", "Correct", and "Learn PHP!" Lol sorry but its true xD
  16. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Excuse me, but your statement is astray from the fact. If you spend some time to look at all my ~7000 posts on the forums, you may find out that I have mentioned "learn PHP" for less than 50 times, and you can barely find a post I write that is not constructive. Say, in this thread, I have pointed out that /msg already exists in PocketMine core. Then we have moved discussion on how to override it, and we are talking about that afterwards, until you bumped in and started talking about /message, which is not related to this thread. I have to admit that the post I wrote ~29 hours before now was written incorrectly because I misread your post, but then I edited it. If we only want to know how to create a simple command, this thread does not have a value and should be locked, as it is definitely duplicated.
    I demand your apology and correction on your irresponsible false statement.
    Vaivez66 likes this.
  17. Vaivez66
    Offline

    Vaivez66 Notable Member Plugin Developer

    Joined:
    Jun 10, 2015
    Posts:
    402
    Plugins:
    2
    "#LearnPHP is a mean culture in PocketMine community." - PEMapModder
    xD
  18. XFuryMCPE
    Offline

    XFuryMCPE Active Member Plugin Developer

    Joined:
    Jun 19, 2015
    Posts:
    137
    Plugins:
    2
    Minecraft User:
    XFuriousMC
    You're excused, mom.
  19. AndrewBit
    Offline

    AndrewBit Notable Member

    Joined:
    Jun 18, 2015
    Posts:
    435
    Minecraft User:
    AndrewBit4
    Please, stop using threads as a chat room!
    Nawaf_Craft1b likes this.
Thread Status:
Not open for further replies.

Share This Page

Advertisement