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

Damage NPC HELP

Discussion in 'Development' started by MrGalletaYTPM, Feb 25, 2020.

  1. MrGalletaYTPM

    MrGalletaYTPM Spider

    Messages:
    9
    Can you help me with this code? The problem is that I want to make the NPC entity harmless when a player touches it and I want it to execute a command or a function

    public function Damage(EntityDamageEvent $event){
    $player = $event->getEntity();
    if($player instanceof EntityDamageByEntityEvent){
    $dama = $event->getDamager();
    if($player instanceof Human && $dama instanceof Player){
    $event->setCancelled();
    $player = $event->getEntity();
    if($player->getNameTag() === "§7§l≥§e FFA§7 ≤§r\n§aTap to play"){
     
  2. Gianluxx

    Gianluxx Slime

    Messages:
    94
    GitHub:
    Gianluxx
    Just copy the code from Slapper plugin on github
     
  3. Gianluxx

    Gianluxx Slime

    Messages:
    94
    GitHub:
    Gianluxx
    btw $player is not an Event
     
  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.