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

Must be instance of pocketmine/item/Item

Discussion in 'Development' started by Noobie, Dec 11, 2016.

  1. Noobie

    Noobie Silverfish

    Messages:
    16
    PHP:
    $item $item->setCustomName(TF::RESET " §6Wallet \n §eMoney: $money ");
                if(
    $level !== null) {
                  
    $level->dropItem(new Vector3(14563178$item));
                } 
    This gives me error that it should be instance of pocketmine/item/Item, null given; but then how do i setCustomName() for that item?
     
  2. Sandertv

    Sandertv Zombie Pigman Poggit Reviewer

    Messages:
    786
    GitHub:
    Sandertv
    What is $item?
     
  3. robske_110 (Tim)

    robske_110 (Tim) Wither Skeleton Poggit Reviewer

    Messages:
    1,342
    GitHub:
    robske110
    Just remove the $item =
     
  4. Noobie

    Noobie Silverfish

    Messages:
    16
    PHP:
    $item Item::get(33901);
     
  5. Noobie

    Noobie Silverfish

    Messages:
    16
    I tried, didn't work
     
  6. robske_110 (Tim)

    robske_110 (Tim) Wither Skeleton Poggit Reviewer

    Messages:
    1,342
    GitHub:
    robske110
    What is the error then?
     
  7. Noobie

    Noobie Silverfish

    Messages:
    16
    Could not execute Task, Argument 2 passed to pocketmine\level\Level::dropitem() must be an instance of pocketmine\item\Item, none given
     
  8. robske_110 (Tim)

    robske_110 (Tim) Wither Skeleton Poggit Reviewer

    Messages:
    1,342
    GitHub:
    robske110
    Are you sure you passed two arguments?
     
  9. Noobie

    Noobie Silverfish

    Messages:
    16
    PHP:
    $item Item::get(33901);
    $item->setCustomName(TF::RESET " §6Wallet \n §eMoney: $money ");
    $level $player->getLevel()->getName();
    $level->dropItem(new Vector3(14563178$item));
    Seems like it.
     
  10. Sandertv

    Sandertv Zombie Pigman Poggit Reviewer

    Messages:
    786
    GitHub:
    Sandertv
    You should make the last line:
    PHP:
    $level->dropItem(new Vector3(14563178), $item));
     
    Magicode and Noobie like this.
  11. Noobie

    Noobie Silverfish

    Messages:
    16
    Ohhhhhhhhhh, thanksssss
     
    Sandertv likes this.
  12. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
    Misplaced closing parenthesis?
     
    Noobie and xBeastMode like this.
  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.