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

Solved Message duplicates

Discussion in 'Development' started by imwood04, Sep 30, 2020.

  1. imwood04

    imwood04 Spider

    Messages:
    6
    GitHub:
    imwood04
    So I made a custom Join/Leave message plugin and when I join or leave the server it sends the message x2 and I need it to send once.

    PHP:
    public function onJoin(PlayerJoinEvent $event)
        {
            
    $event->setJoinMessage("");
            
    $player $event->getPlayer();
            
    $name $player->getName();
            
    $this->getServer()->broadcastMessage(TF::GREEN "$name Has Joined the Server!");
        }

        public function 
    onQuit(PlayerQuitEvent $event)
        {
            
    $event->setQuitMessage("");
            
    $player $event->getPlayer();
            
    $name $player->getName();
            
    $this->getServer()->broadcastMessage(TF::RED "$name Has Quit the Server!");

        }
     

    Attached Files:

  2. wolfdale

    wolfdale Zombie Pigman

    Messages:
    535
    GitHub:
    diamond-gold
    You probably registered your listener twice
    Easy fix
    PHP:
    $event->setJoinMessage(TF::GREEN "$name Has Joined the Server!"); 
    $event->setQuitMessage(TF::RED "$name Has Quit the Server!");
     
    imwood04 likes this.
  3. imwood04

    imwood04 Spider

    Messages:
    6
    GitHub:
    imwood04
  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.