Solved Whats problem

Discussion in 'Development' started by Mohamad, Jan 10, 2020.

  1. Mohamad

    Mohamad Silverfish

    Messages:
    18
    public function onDamage(EntityDamageByEntityEvent $event){
    if($event->getDamager() instanceof Player and $event->getEntity() instanceof Player){
    $damager = $event->getDamager();
    $ih = $damager->getInventory()->getItemInHand();
    if($ih->getId() == 280){
    $pl = $event->getEntity();
    $pl->setMotion(new Vector3(0, 8, 0));
    $pl->sendMessage(TF::GOLD."Author".TF::RED.":".TF::GREEN." PeGaH\n".TF::GOLD."TelegramID".TF::RED.":".TF::GREEN." @P_3_G_A_H");
    }
    }
    }

    why this code dont work?
    i want to make a this plugin :
    if player1 damage to player2 with stick in hands player2 jump
     
  2. Gianluxx

    Gianluxx Slime

    Messages:
    96
    GitHub:
    Gianluxx
    Any errors? Is the plugin loaded?
     
  3. Mohamad

    Mohamad Silverfish

    Messages:
    18
    yes plugin loaded and command are working but player1 damage time with stick player2 dont jump and dont send message
     
  4. Gianluxx

    Gianluxx Slime

    Messages:
    96
    GitHub:
    Gianluxx
    Try adding some print("test"); in the code to check where it stops
     
  5. Mohamad

    Mohamad Silverfish

    Messages:
    18
    i add, and code dont work
    i think onDamage have a problem
     
  6. Gianluxx

    Gianluxx Slime

    Messages:
    96
    GitHub:
    Gianluxx
    Did you implement listener?
     
  7. Mohamad

    Mohamad Silverfish

    Messages:
    18
    no. i should implement listener?
     
  8. Mohamad

    Mohamad Silverfish

    Messages:
    18
    now i implement listener but dont work again
     
  9. Gianluxx

    Gianluxx Slime

    Messages:
    96
    GitHub:
    Gianluxx
    register events in onEnable
     
  10. Mohamad

    Mohamad Silverfish

    Messages:
    18
    thanks, working whith register event
     

Share This Page

  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.