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

Event help

Discussion in 'Development' started by Teamblocket, Oct 22, 2017.

  1. Teamblocket

    Teamblocket Zombie

    Messages:
    301
    GitHub:
    teamblocket
    This code doesn't work :p

    PHP:
    public function onPlayerEvents(\pocketmine\event\player\PlayerEvent $ev){

    if(
    $ev instanceof PlayerJoinEvent){
    $ev->getPlayer()->sendMessage(' test ');
    }
    }
     
  2. Irish

    Irish Baby Zombie

    Messages:
    156
    GitHub:
    irishpacks
    Because it doesn't have a handler list :facepalm:

    Just do:
    PHP:
    public function onPlayerJoin(\pocketmine\event\player\PlayerJoinEvent $event) {
        
    $event->getPlayer()->sendMessage("test");
    }
     
  3. Levi

    Levi Skeleton

    Messages:
    955
    GitHub:
    captainleviftw
    why make your life harder?
     
  4. Thunder33345

    Thunder33345 Moderator Staff Member

    Messages:
    2,137
    GitHub:
    Thunder33345
    how is this helping?
    who knows what OP wanted to do, op just want an explanation and that's all
    what if OP want to log all player events?
    so is registering every single event "easier"?
     
  5. Levi

    Levi Skeleton

    Messages:
    955
    GitHub:
    captainleviftw
  6. Thunder33345

    Thunder33345 Moderator Staff Member

    Messages:
    2,137
    GitHub:
    Thunder33345
    OP; Original poster
    normally used in threads implying the person who created the thread without mentioning or saying op's name
    never to be confused with OP; [Server] Operator
    normally used to imply people in/have control of the said server/network
     
    HimbeersaftLP and EdwardHamHam like this.
  7. MasterNice

    MasterNice Spider

    Messages:
    11
    PHP:
    public function onJoin(PlayerJoinEvent $event){
    $event->getPlayer()->sendMessage("Blablabla");
    }
     
    Levi likes this.
  8. Teamblocket

    Teamblocket Zombie

    Messages:
    301
    GitHub:
    teamblocket
    Is it possible to add a handler list?
     
  9. Irish

    Irish Baby Zombie

    Messages:
    156
    GitHub:
    irishpacks
    Without modifying the source? No. Although, you can make custom events and give them a handler list.
     
    Levi and jasonwynn10 like this.
  10. Teamblocket

    Teamblocket Zombie

    Messages:
    301
    GitHub:
    teamblocket
    example?
     
  11. jasonwynn10

    jasonwynn10 Moderator Poggit Reviewer

    Messages:
    1,489
    GitHub:
    jasonwynn10
  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.