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

Get Player Kill Entity

Discussion in 'Facepalm' started by Bintang Putra, Jun 6, 2017.

  1. Bintang Putra

    Bintang Putra Witch

    Messages:
    63
    GitHub:
    chaostixzix
    Hi, I'm trying to make a quest plugins that required Player to kill some monster.
    My question is. How to check if the player already killed a spesific monster, example : enderman

    Thank You
    i'm sorry, i'm a newbie at php
     
  2. Bintang Putra

    Bintang Putra Witch

    Messages:
    63
    GitHub:
    chaostixzix
    Why Was This A Facepalm Post?
     
  3. corytortoise

    corytortoise Skeleton

    Messages:
    825
    GitHub:
    corytortoise
  4. Bintang Putra

    Bintang Putra Witch

    Messages:
    63
    GitHub:
    chaostixzix
  5. corytortoise

    corytortoise Skeleton

    Messages:
    825
    GitHub:
    corytortoise
    Once you have the instance of EntityDamageByEntityEvent, $event->getDamager(). You'll have to check if it is a player though.
     
  6. Bintang Putra

    Bintang Putra Witch

    Messages:
    63
    GitHub:
    chaostixzix
    So , Use instanceif Player? Then Check the name?
     
  7. corytortoise

    corytortoise Skeleton

    Messages:
    825
    GitHub:
    corytortoise
    instanceof, yes. You don't have to check the name to confirm that it is a player, but if you want to see if it is a certain player, you would.
     
  8. Bintang Putra

    Bintang Putra Witch

    Messages:
    63
    GitHub:
    chaostixzix
    How if i want to get when the player killed not damaged
     
  9. corytortoise

    corytortoise Skeleton

    Messages:
    825
    GitHub:
    corytortoise
    Listen for EntityDeathEvent, then use Entity->getLastDamageCause. From there, you can check if it's an EntityDamageByEntityEvent, etc.
     
  10. Bintang Putra

    Bintang Putra Witch

    Messages:
    63
    GitHub:
    chaostixzix
    Thanks, I'll try it

    How to check it? using instanceof?
     
  11. corytortoise

    corytortoise Skeleton

    Messages:
    825
    GitHub:
    corytortoise
    Yes.
     
  12. Bintang Putra

    Bintang Putra Witch

    Messages:
    63
    GitHub:
    chaostixzix
    Thanks :D
     
  13. Bintang Putra

    Bintang Putra Witch

    Messages:
    63
    GitHub:
    chaostixzix
    Tried This, but not working.
    i kill player with lava

    its working when i use BlockBreakEvent
    PHP:
    public function onKill(EntityDeathEvent $event)
    {
        
    var_dump("Test");
    }
     
  14. corytortoise

    corytortoise Skeleton

    Messages:
    825
    GitHub:
    corytortoise
    Any errors? Can I see what you used for BlockBreakEvent? Did you try them both in the exact same environments?
     
  15. Bintang Putra

    Bintang Putra Witch

    Messages:
    63
    GitHub:
    chaostixzix
    yep i tried them on the same enviroment.
    i used lava for entitydeathevent nothing shows on console.

    when i use blockbreakevent, its shows Test on console
     
  16. Kenn Fatt

    Kenn Fatt Slime

    Messages:
    82
    GitHub:
    kennfatt
    im sorry to speak using local language (Bahasa Indonesia) i hope he will understand later.

    Jadi maksudnya gmna mas, saya bantu sini :D
     
  17. Bintang Putra

    Bintang Putra Witch

    Messages:
    63
    GitHub:
    chaostixzix
    Kennan? di fb aja
     
  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.