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

Solved Scan inventory

Discussion in 'Development' started by Matrox, Jun 8, 2019.

  1. Matrox

    Matrox Slime

    Messages:
    92
    GitHub:
    MatroxMC
    How to scan the inventory to see if an item is in it?
     
  2. jasonwynn10

    jasonwynn10 Moderator Poggit Reviewer

    Messages:
    1,489
    GitHub:
    jasonwynn10
    HimbeersaftLP likes this.
  3. Matrox

    Matrox Slime

    Messages:
    92
    GitHub:
    MatroxMC
  4. jasonwynn10

    jasonwynn10 Moderator Poggit Reviewer

    Messages:
    1,489
    GitHub:
    jasonwynn10
  5. Matrox

    Matrox Slime

    Messages:
    92
    GitHub:
    MatroxMC
  6. VincBros

    VincBros Silverfish

    Messages:
    19
    GitHub:
    vincbros
    I know this is an old thread, but how can I "total the getCount() function from each returned item into one variable?" This is what I've done so far:

    $items = Item::get(4, 0, 1);
    foreach ($inventory->all($items) as $item){
    $count = $item->getCount();
    return $count;
    }
     
  7. Diduhless

    Diduhless Baby Zombie

    Messages:
    199
    GitHub:
    Diduhless
    PHP:
    $item_count 0;
    /** @var Item $item */
    foreach($inventory->all(Item::get(Item::COBBLESTONE)) as $item) {
        
    $item_count += $item->getCount();
    }
     
    Last edited: Oct 1, 2020
  8. VincBros

    VincBros Silverfish

    Messages:
    19
    GitHub:
    vincbros
    Thanks! I’ll try it.
     
  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.