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

upgrade amor

Comments in 'Plugin Development' started by PaulchenHD, Mar 20, 2016.

  1. PaulchenHD
    Offline

    PaulchenHD Active Member

    Joined:
    Jan 17, 2016
    Posts:
    111
    Minecraft User:
    Paulchen_HD
    how to upgrade amor by killing players ?
    1. full leather -> full chain
    please help me ;)
    PHP:
        public function onPlayerDeathEvent(PlayerDeathEvent $event)
         {
           
    $player $event->getEntity();
         
           if (
    $player instanceof Player)
           {
             
    $cause $player->getLastDamageCause();
         
             if(
    $cause instanceof EntityDamageByEntityEvent)
             {
               
    $damager $cause->getDamager();
               
               if(
    $damager instanceof Player)
               {
      
    $damager->sendMessage(Color::GREEN."test");
       
                 
    $this->money->addMoney($damager5);
               
                 
    $this->money->reduceMoney($player5);
  2. minebuilder0110
    Offline

    minebuilder0110 Notable Member

    Joined:
    Dec 8, 2014
    Posts:
    485
    Minecraft User:
    Apparitional
  3. PaulchenHD
    Offline

    PaulchenHD Active Member

    Joined:
    Jan 17, 2016
    Posts:
    111
    Minecraft User:
    Paulchen_HD
  4. minebuilder0110
    Offline

    minebuilder0110 Notable Member

    Joined:
    Dec 8, 2014
    Posts:
    485
    Minecraft User:
    Apparitional
    You would call that function on inventory object.
    $player->getInventory()->setHelmet($item);
    PaulchenHD and Survingo like this.
  5. Survingo
    Offline

    Survingo Active Member

    Joined:
    Dec 6, 2015
    Posts:
    221
    PHP:
        public function getHelmet(){
            return 
    $this->getItem($this->getSize());
        }
        public function 
    getChestplate(){
            return 
    $this->getItem($this->getSize() + 1);
        }
        public function 
    getLeggings(){
            return 
    $this->getItem($this->getSize() + 2);
        }
        public function 
    getBoots(){
            return 
    $this->getItem($this->getSize() + 3);
        }
        public function 
    setHelmet(Item $helmet){
            return 
    $this->setItem($this->getSize(), $helmet);
        }
        public function 
    setChestplate(Item $chestplate){
            return 
    $this->setItem($this->getSize() + 1$chestplate);
        }
        public function 
    setLeggings(Item $leggings){
            return 
    $this->setItem($this->getSize() + 2$leggings);
        }
        public function 
    setBoots(Item $boots){
            return 
    $this->setItem($this->getSize() + 3$boots);
        }

    // What you do not understand?
    // Just add leather armor id and here you goes
    PHP:
    if($player->getInventory()->getHelmet(Item::get(29801)) and $player->getInventory()->getChestplate(Item::get(29901)) and $player->getInventory()->getLeggings(Item::get(30001)) and $player->getInventory()->getBoots(Item::get(30101))) {
    $player->getInventory()->setHelmet(Item::get(3020,1));
    $player->getInventory()->setChestplate(Item::get(30301));
    $player->getInventory()->setLeggings(Item::get(30401));
    $player->getInventory()->setBoots(Item::get(3050,1));
    }
    // Leather armor to chainmail armor
    // You could edit all $player to $damager like in your code
    Last edited: Mar 20, 2016
    Skullex, Primus and PaulchenHD like this.
  6. PaulchenHD
    Offline

    PaulchenHD Active Member

    Joined:
    Jan 17, 2016
    Posts:
    111
    Minecraft User:
    Paulchen_HD
    omg it works THANK YOU SOOOOOOOO MUCH YOUR THE BEST ! ;)
    JackboyPlay and Survingo like this.
  7. PaulchenHD
    Offline

    PaulchenHD Active Member

    Joined:
    Jan 17, 2016
    Posts:
    111
    Minecraft User:
    Paulchen_HD
  8. Survingo
    Offline

    Survingo Active Member

    Joined:
    Dec 6, 2015
    Posts:
    221
    @PaulchenHD I can't skype. How about Privat conversation?

Share This Page

Advertisement