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

Solved disable chat

Comments in 'Plugin Development' started by TryoneLegendZzz, Oct 18, 2015.

  1. TryoneLegendZzz
    Offline

    TryoneLegendZzz Active Member

    Joined:
    May 31, 2015
    Posts:
    201
    Minecraft User:
    SavionLegendZzz
    how can i disable chat for a player(like player messages, but keep broadcast(s))?
  2. TryoneLegendZzz
    Offline

    TryoneLegendZzz Active Member

    Joined:
    May 31, 2015
    Posts:
    201
    Minecraft User:
    SavionLegendZzz
    i tried lookimg at other chat-disablers soruce code but i dont really get it:confused:
  3. zombie_Power
    Offline

    zombie_Power Active Member

    Joined:
    Sep 7, 2015
    Posts:
    239
    Minecraft User:
    Zombie_Power
    what do you mean? can you please be a little more specific (example maybe?)? :)
  4. Artide
    Offline

    Artide Active Member

    Joined:
    Apr 20, 2015
    Posts:
    214
    Minecraft User:
    Artide5
    PHP:
    public function onPlayerChat(PlayerChatEvent $e){
    $e->setCancelled(true);//Cancell player chat
    $this->getServer()->broadcastMessage("Hello Players!");// broadcast "hello players!" to all the players online
    }
  5. Gamecrafter
    Offline

    Gamecrafter

    Joined:
    Nov 20, 2014
    Posts:
    978
    Plugins:
    9
    PHP:
    public function onPlayerChat(\pocketmine\event\player\PlayerChatEvent $event){
        
    $event->setCancelled();
    }
    But what do you mean by "broadcasts"? Are you trying to make a chat mute plugin? Please be more specific, that way we can help you solve your problem faster.
  6. Hotshot_9930
    Offline

    Hotshot_9930 Notable Member Plugin Developer

    Joined:
    May 26, 2014
    Posts:
    665
    Plugins:
    2
    Minecraft User:
    HotshotHD
    Broadcasts and player messages arent connected. Cancelling the PlayerChatEvent should do it.
  7. CaptainKenji17
    Offline

    CaptainKenji17 Active Member

    Joined:
    Apr 22, 2014
    Posts:
    252
    Minecraft User:
    CaptainKenji17

    he means like the /chat-off on GrabBag https://github.com/alejandroliu/poc...ter/GrabBag/src/aliuly/grabbag/CmdChatMgr.php
  8. TryoneLegendZzz
    Offline

    TryoneLegendZzz Active Member

    Joined:
    May 31, 2015
    Posts:
    201
    Minecraft User:
    SavionLegendZzz
  9. tigerza118
    Offline

    tigerza118 Active Member

    Joined:
    Jan 31, 2015
    Posts:
    100
    Minecraft User:
    tigerza117
    PHP:
    public function onPlayerChat(\pocketmine\event\player\PlayerChatEvent $event){
        
    $event->setCancelled();
       foreach(
    $this->getServer()->getOnlinePlayers() as $p){
          
    $p->send...........................
        }
    }
  10. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    or just Server::broadcastMessage($message);
  11. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    What's the point of cancelling PlayerChatEvent and then broadcasting it again?

    You should use PlayerChatEvent->setRecipients() instead.
    CrazedMiner likes this.
  12. CrazedMiner
    Offline

    CrazedMiner Notable Member Plugin Developer

    Joined:
    Jan 31, 2015
    Posts:
    348
    Plugins:
    2
    Minecraft User:
    CrazedMinerYT
    Keep an array of players that are muted and player's that can't receive messages, when a player chats that is muted cancel the event and for the players that can't receive messages do:
    PHP:
    foreach($server->getOnlinePlayers() as $player) {
        if(!isset(
    $doNotReciveChat[$player->getName()])) {
            
    $player->sendMessage($message);
        }
    }
  13. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Use getRecipients() and setRecipients() >.<
    CrazedMiner and jojoe77777 like this.

Share This Page

Advertisement