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

NPC Solution?

Discussion in 'Development' started by TheTrollArtz, Jun 4, 2018.

  1. TheTrollArtz

    TheTrollArtz Spider

    Messages:
    13
    GitHub:
    ithetrollidk
    How do I make it work, by hitting the PC since my code does not work..

    PHP:
    public function onDamage(EntityDamageEvent $e){
        
    $o = $e->getEntity();
        if(
    $e instanceof EntityDamageByEntityEvent){
          
    $d = $e->getDamager();
          if(
    $d instanceof Player && $o instanceof NPCFfa){
              
    $e->setCancelled();
              
    $player = $d;
              
    $sender = $d;
          
    $this->getServer()->loadLevel("ffa");
              
    $count = count($this->getServer()->getLevelByName("ffa")->getPlayers());
               if(
    $o->getNameTag() === "§bFree for All\n§eTouch to play!"){
         
    $this->getServer()->loadLevel("ffa");
         
    $player->teleport($this->getServer()->getLevelByName("ffa")->getSpawnLocation());
                
    $player->sendMessage("§cTe has unido a FFA\n§b".$player->getName()."§c Te deseamos suerte!");
                
    $player->setFood(20);
        
    $player->setHealth(20);
        
    $player->addTitle("§3§lFFA§r", "§7» §f¡Enjoy your stay! §7«");
        
    $player->getInventory()->clearAll();
        
    $casco = Item::get(Item::DIAMOND_HELMET, 0, 1);
    $casco->setCustomName("§bCasco De Diamante");
    $player->getArmorInventory()->setHelmet($casco);
    $peto = Item::get(Item::DIAMOND_CHESTPLATE, 0, 1);
    $peto->setCustomName("§bPechera De Diamante");
    $player->getArmorInventory()->setChestplate($peto);
    $pantalon = Item::get(Item::DIAMOND_LEGGINGS, 0, 1);
    $pantalon->setCustomName("§bPantalones De Diamante");
    $player->getArmorInventory()->setLeggings($pantalon);
    $botas = Item::get(Item::DIAMOND_BOOTS, 0, 1);
    $botas->setCustomName("§bBotas De Diamante");
    $player->getArmorInventory()->setBoots($botas);
    $player->getInventory()->addItem(Item::get(276,0,1));
    $manzana = Item::get(Item::GOLDEN_APPLE);
    $manzana->setDamage(20);
    $manzana->setCount(6);
    $manzana->setCustomName("§6Golden Head");
    $player->getInventory()->addItem($manzana);
               }}}}
     
  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.