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

why error?

Comments in 'Plugin Development' started by musaichi, Nov 14, 2015.

  1. musaichi
    Offline

    musaichi New Member

    Joined:
    Mar 2, 2015
    Posts:
    33
    Minecraft User:
    musaichi
    hi everyone:) please help me:(
    why does plugin error?

    Error:Call to a member function setArmorItem() on null[206]

    public function onJoin(PlayerJoinEvent $event){
    $player = $event->getPlayer();
    $name = $player->getName();
    $H = $this->h;
    $T = $this->t;
    if($this->game == false){
    $this->players = $this->players + 1;
    if($H > $T / 4){
    [206]$player->getInventory()->setArmorItem(0,Item::get(298,0,1));
    $player->getInventory()->sendArmorContents($player);
    $this->t = $T + 1;
    $player->setNameTagVisible(false);
    $player->removeAllEffects();
    }elseif($H < $T){
    $player->getInventory()->setArmorItem(0,Item::get(310,0,1));
    $player->getInventory()->sendArmorContents($player);
    $this->h = $H + 1;
    $player->setNameTagVisible(false);
    $effect = Effect::getEffect(1);
    $effect->setDuration(114514);
    $effect->setAmplifier(3);
    $effect->setVisible(true);
    $player->addEffect($effect);
    }elseif($H == $T){
    $player->getInventory()->setArmorItem(0,Item::get(298,0,1));
    $player->getInventory()->sendArmorContents($player);
    $this->t = $T + 1;
    $player->removeAllEffects();
    return true;
    }
    }
    if($this->game === true){
    $player->getInventory()->setArmorItem(0,Item::get(314,0,1));
    $player->getInventory()->sendArmorContents($player);
    }
    }
  2. zombie_Power
    Offline

    zombie_Power Active Member

    Joined:
    Sep 7, 2015
    Posts:
    239
    Minecraft User:
    Zombie_Power
    Please use [ PHP ][/PHP] next time.
    I am unsure, as I have never used setArmorItem before (or seen it).
    Instead, you should do:
    PHP:
    $player->getInventory->setItem($slotItem:get(/*add you item Id here*/);
    Last edited: Nov 16, 2015
    musaichi likes this.
  3. k3ithkfng
    Offline

    k3ithkfng Active Member

    Joined:
    Jul 9, 2015
    Posts:
    91
    Minecraft User:
    K3ith
    Eh... One of the code fields are blank. Maybe you should fill it in, instead of giving him the feeling you haven't answered his post completely? Please correct me if I'm wrong.
    musaichi and zombie_Power like this.
  4. zombie_Power
    Offline

    zombie_Power Active Member

    Joined:
    Sep 7, 2015
    Posts:
    239
    Minecraft User:
    Zombie_Power
    I am on my iPad. I may have accidentally pressed a wrong button. Thanks for the reminder. :)
    musaichi likes this.
  5. k3ithkfng
    Offline

    k3ithkfng Active Member

    Joined:
    Jul 9, 2015
    Posts:
    91
    Minecraft User:
    K3ith
    Lol. I always use my iPad and I never make a mistake(totally)!
    musaichi likes this.
  6. jojoe77777
    Offline

    jojoe77777 Notable Member Plugin Developer

    Joined:
    May 28, 2015
    Posts:
    653
    Plugins:
    1
    Minecraft User:
    jojoe77777
    They meant to do [php][/php]
    musaichi and KubixQ like this.

Share This Page

Advertisement