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

Help with entity

Comments in 'Plugin Development' started by TheMaks, Aug 13, 2015.

  1. TheMaks
    Offline

    TheMaks Active Member

    Joined:
    Jul 19, 2015
    Posts:
    58
    Minecraft User:
    TheMaks
    I want to do that would be by killing a player who killed giving diamonds , but I have a problem with
    public function onEntity(EntityDamageEvent $event){
    $player = $event->getEntity();
    if($event instanceof EntityDamageEvent){
    $killer = $event->getDamager();
    if($player instanceof Player && $killer instanceof Player){
    $msg = $this->getServer()->getInstance()->broadcastMessage($p . " был убит " . $killer);
    $item = Item::get(57);
    $item->setCount(64);
    $killer->getInventory()->addItem($item);
    return $msg;
    }
    }
    }
    the code
  2. TheMaks
    Offline

    TheMaks Active Member

    Joined:
    Jul 19, 2015
    Posts:
    58
    Minecraft User:
    TheMaks
    It should be that when one player killed 2 player , then 2 should give a thing , I know that through PlayerDeathEvent dead player can only have the one if I'm wrong then help me, how to get the name of the killer
  3. Xenturio
    Offline

    Xenturio Active Member

    Joined:
    Sep 19, 2014
    Posts:
    333
    Minecraft User:
    Xenturio
    lastdamagecouse instance of EntityDamagebyEntityEvent
    getdamager->getName
  4. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,472
    Minecraft User:
    PrimusLV
    PHP:
    public function onDeath(PlayerDeathEvent $event){
    if(
    $event->getPlayer()->getLastDamageCause() instanceof EntityDamageByEntityEvent){
    $item Item::get(26402)
    $event->getPlayer()->getLastDamageCause()->getDamager()->getInventory()->addItem($item);
    }
    }
  5. Xenturio
    Offline

    Xenturio Active Member

    Joined:
    Sep 19, 2014
    Posts:
    333
    Minecraft User:
    Xenturio
    $event->getPlayer()->getLastDamageCause()

    it is an entity event not a player event or not?

    $event->getEntity()->getLastDamageCause()
    PEMapModder likes this.
  6. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,472
    Minecraft User:
    PrimusLV
    I was writing it on Android :p
  7. Gamecrafter
    Offline

    Gamecrafter Notable Member Plugin Developer

    Joined:
    Nov 20, 2014
    Posts:
    981
    Plugins:
    9
    It hurts my eyes. Please put the code in a code block.
    PEMapModder likes this.

Share This Page

Advertisement