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

how to use a event?

Comments in 'Plugin Development' started by Seetch, Jul 2, 2015.

  1. Seetch
    Offline

    Seetch New Member

    Joined:
    Feb 5, 2015
    Posts:
    22
    Minecraft User:
    Seetch
    What event should I use? Here is the code:
    PHP:
    use pocketmine\event\player\PlayerDeathEvent;

    //my code//kits
    public function onPlayerDeath(PlayerDeathEvent $event){
            if(isset(
    $this->sessions[$event->getEntity()->getName()])){
                unset(
    $this->sessions[$event->getEntity()->getName()]);
            }
        }
    I can not solve this problem by killing the whale-start is not possible to receive and dying whale start again turns.

    Sorry, my bad English.
  2. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    Use in_array instead of isset and $event->getPlayer()->getName(). Also, did you register the Event?
    Xenturio likes this.
  3. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Why? How do you know that he didn't intend to use names as keys?

    And it should be $event->getEntity(). Don't reply unless you are sure it is correct.

    And how come someone liked that post?
    Seetch likes this.

Share This Page

Advertisement