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

How to know how the player died?

Comments in 'Plugin Development' started by Sergey_D, Nov 9, 2014.

  1. Sergey_D
    Offline

    Sergey_D Active Member

    Joined:
    Jan 19, 2014
    Posts:
    75
    Minecraft User:
    CLILLZ
    how to know how the player died from PlayerDeathEvent or EntityDeathEvent?
    P.S. Bad English.
  2. DeBe
    Offline

    DeBe New Member

    Joined:
    May 29, 2014
    Posts:
    15
    Minecraft User:
    DeBe
    use EntitiDeathEvent
    + if($event->getEntity() instanceof Player){

    or

    just use PlayerDeathEvent
  3. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Just use playerdeathevent. It is faster.

    I mean, it is faster for PocketMine to fire the event, not faster for you to code, although indeed both are true.
    EvolSoft and LDX like this.
  4. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    As my last check, EntityDeathEvent doesn't seem to be fired for player deaths.
  5. Sergey_D
    Offline

    Sergey_D Active Member

    Joined:
    Jan 19, 2014
    Posts:
    75
    Minecraft User:
    CLILLZ
    I want to know the cause of death
  6. ProjectInfinity
    Offline

    ProjectInfinity Active Member Plugin Developer

    Joined:
    Sep 7, 2014
    Posts:
    112
    Plugins:
    3
    Minecraft User:
    ProjectInfinity
    For this I think you need to listen to EntityDamageEvent and check if the damage dealt is greater than the remaining health. To get the cause you do event->getCause().

    Edit: After digging through the documentation you can do the following.
    • Listen for PlayerDeathEvent
    • Check cause by doing event->getEntity()->getLastDamageCause().
    That SHOULD do the same as what I previously described.
    Last edited: Nov 10, 2014
    EvolSoft likes this.

Share This Page

Advertisement