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

Item Count

Discussion in 'Development' started by Pqoster, Sep 5, 2020.

  1. Pqoster

    Pqoster Spider Jockey

    Messages:
    25
    How do I get how many pots were left when the player died?
     
  2. xLeakDev Enzo

    xLeakDev Enzo Spider Jockey

    Messages:
    38
    GitHub:
    nya-enzo
    stop reposting thread many times
     
  3. Matrox

    Matrox Slime

    Messages:
    92
    GitHub:
    MatroxMC
    PHP:
        public function getPotionCount(Player $sender){
            
    $name $sender->getName();
            
    $number 0;
            
    $inventory $sender->getInventory();
            foreach(
    $inventory->getContents() as $item){
                if (
    $item instanceof \pocketmine\item\Potion or $item instanceof \pocketmine\item\SplashPotion) {
                    
    $number $number $item->getCount();
                }
            }

            return 
    $number
        }

    //returns the number of potions left
    $this->getPotionCount($sender)
     
     
  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.