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

Solved How to add an array of items?

Discussion in 'Development' started by Atomization, Jun 7, 2018.

  1. Atomization

    Atomization Baby Zombie

    Messages:
    120
    GitHub:
    iAtomPlaza
    Hey, How can i add an Array of items to the players inventory?
    PHP:
    $items_array = (array) $config->get($args[0].".items"); //gets the array of items from config

    foreach($items_array as $items){ //loops though the array

        
    $player->getInventory()->addItem(Item::get($items01)); //supposed to (but not work) give all the items to the player

    }
    I get no error but the code doesn't give the player any of the items in the array.[/PHP]
     
  2. Atomization

    Atomization Baby Zombie

    Messages:
    120
    GitHub:
    iAtomPlaza
    just moments after posting i changed:
    PHP:
    $config->get()
    TO
    PHP:
    $config->getNested()
    and it worked... i feel stupid rn lol
     
  3. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
    or $config->get($args[0])["items"]
     
  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.