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

PlayerChatEvent

Discussion in 'Facepalm' started by Teamblocket, Apr 16, 2017.

  1. Teamblocket

    Teamblocket Zombie

    Messages:
    301
    GitHub:
    teamblocket
    hey , can someone tell me how i can make PlayerChatEvent cancel a players message?
     
  2. XdmingXD

    XdmingXD Baby Zombie

    Messages:
    158
    GitHub:
    xdmingxd
    PHP:
    $event->setCancelled(true);
     
  3. BouncyJeffer

    BouncyJeffer Spider Jockey

    Messages:
    39
    GitHub:
    bouncyjeffer
    public function onChat(PlayerChatEvent $event){
    $event->setCancelled(true);
    }
     
  4. Teamblocket

    Teamblocket Zombie

    Messages:
    301
    GitHub:
    teamblocket
    ttthhhxxxx
     
  5. BouncyJeffer

    BouncyJeffer Spider Jockey

    Messages:
    39
    GitHub:
    bouncyjeffer
    No problem!
     
  6. Teamblocket

    Teamblocket Zombie

    Messages:
    301
    GitHub:
    teamblocket
    how can i save message to config ik i have to use getMessage() and $this->getConfig()->save("blal");
     
  7. moska

    moska Baby Zombie

    Messages:
    105
    GitHub:
    supermaxalex
    PHP:
    $this->getDefaultConfig()->set($event->getPlayer()->getName(), $event->getMessage());
    $this->getDefaultConfig()->save();
     
    Teamblocket likes this.
  8. jasonwynn10

    jasonwynn10 Moderator Poggit Reviewer

    Messages:
    1,489
    GitHub:
    jasonwynn10
    getDefaultConfig() isn't a function native to PluginBase
    PHP:
    $this->getConfig()->set($event->getPlayer()->getName(), $event->getMessage());
    $this->getConfig()->save();
     
  9. moska

    moska Baby Zombie

    Messages:
    105
    GitHub:
    supermaxalex
    Lmao, ya sorry xD
     
  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.