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

Snowball damage

Discussion in 'Help' started by Fineeno, Jan 27, 2018.

  1. Fineeno

    Fineeno Creeper

    Messages:
    2
    GitHub:
    FIneno
    Hi. I can not get the attacker from the player who attacks with snowballs.
    I need each snowball to deal damage in 5 hp and 4 snowballs to kill the player being attacked.
    Whats wrong?
    public function onDamage(EntityDamageEvent $event)
    {
    $player = $event->getEntity();
    if($player->getLevel() == $this->getServer()->getLevelByName('4b'))
    {
    if($event->getCause() == EntityDamageEvent::CAUSE_PROJECTILE)
    {
    $event->setDamage(5);
    }
    if ($event instanceof EntityDamageByEntityEvent)
    {
    $damager = $event->getDamager();
    if(!isset($this->FBStatus[$player->getName()]))
    {
    if($player instanceof Player and $event->getCause() == EntityDamageEvent::CAUSE_PROJECTILE and round($event->getFinalDamage()) >= $player->getHealth() or $damager->getInventory()->getItemInHand()->getId() == 294 )
    {
    $player->setHealth(20);
    $this->FBStatus[$player->getName()] = 0;
    $player->hidePlayer($player);
    $event->setCancelled(true);
    $player->sendTitle(TextFormat::RED.'УБИТ');
    $damager->sendTitle(TextFormat::RED.'KILL', '+50$');
    $this->FBMoney[$damager->getName()] += 50;
    $this->economy->addMoney($damager, 50);
     
  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.