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

sendChat() in Command Handler Problem

Comments in 'Plugin Development' started by SuperChipsLP, Oct 19, 2013.

  1. SuperChipsLP
    Offline

    SuperChipsLP Active Member Plugin Developer

    Joined:
    Sep 15, 2013
    Posts:
    204
    Plugins:
    5
    Minecraft User:
    Redmol
    Hey there!

    I try to use sendChat in a command handler, but that doesn't work...

    PHP:
    $data["issuer"]->sendChat("VOTING");
    The commands are registered of course.
    How do i use sendChat correctly?

    Thanks

    ~Niki
    Last edited: Oct 19, 2013
  2. wies
    Offline

    wies Notable Member

    Joined:
    Aug 23, 2013
    Posts:
    392
    PHP:
    $issuer->sendChat("VOTING");
    But I would advice you to return a string when using the command handler, because sendChat doesn't work in the console
  3. SuperChipsLP
    Offline

    SuperChipsLP Active Member Plugin Developer

    Joined:
    Sep 15, 2013
    Posts:
    204
    Plugins:
    5
    Minecraft User:
    Redmol
    Server is still crashing...
  4. SuperChipsLP
    Offline

    SuperChipsLP Active Member Plugin Developer

    Joined:
    Sep 15, 2013
    Posts:
    204
    Plugins:
    5
    Minecraft User:
    Redmol
    Moment. I can't use it in the console? That explained everything to me. Thanks :D
  5. wies
    Offline

    wies Notable Member

    Joined:
    Aug 23, 2013
    Posts:
    392
    PHP:
    public function command($cmd$args$issuer){
      return 
    "this works in the console and in-game";
    }
  6. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Aint it sendchat in lowercase?
  7. onebone
    Offline

    onebone Notable Member Plugin Developer

    Joined:
    Aug 31, 2013
    Posts:
    330
    Plugins:
    7
    Minecraft User:
    onebone
    You may use like this:
    PHP:
    public function commandHandler($cmd$param$issuer$alias){
    $output ""// Set the variable $output
    switch($cmd){
    case 
    "vote":
    $output .= "Voted successfully."// Set the message
    break;
    }
    return 
    $output// Returns message to ConsoleAPI
    }
    It can used by Console and also Players
  8. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    So what does ConsoleAPI do with returned value?
  9. onebone
    Offline

    onebone Notable Member Plugin Developer

    Joined:
    Aug 31, 2013
    Posts:
    330
    Plugins:
    7
    Minecraft User:
    onebone
    ConsoleAPI sends message to the issuer
  10. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Literally "return" : )

Share This Page

Advertisement