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

Elytra

Discussion in 'Facepalm' started by Theo gillespie, Nov 15, 2017.

  1. Theo gillespie

    Theo gillespie Spider

    Messages:
    13
    How do I give a player a item
     
  2. Vaxrp

    Vaxrp Witch

    Messages:
    73
    GitHub:
    Vaxrp
    Bro... Really?
    Anyways

    If you mean like on an event like PlayerJoinEvent()
    do
    PHP:
    onJoin(PlayerJoinEvent $event){
    $player $event->getPlayer();//Gets the player you want to send item too.
    $item $player->getItem();
    //Actual giving the player something
    $player->getInventory()->addItem(Item::GOLDEN_APPLE);//Gives the item.
    //GIVES THE PLAYER THE ITEM WHEN THEY JOIN. 
     
  3. Theo gillespie

    Theo gillespie Spider

    Messages:
    13
    Thanks, but how do I give a group of people a item.
     
  4. WinterBuild7074

    WinterBuild7074 Zombie Pigman

    Messages:
    693
    GitHub:
    winterbuild7074
    PHP:
    /**
     * @var Item $item
     */
    $players = ["person1""player2""user3""blablabla"];

    foreach(
    $players as $player) {
        
    $player $this->getServer()->getPlayer($player);
        if(
    $player) { // checks if player is online, returns NULL (= false) if player not online/not found
            
    $player->getInventory()->addItem($item);
        }
    }
     
  5. jasonwynn10

    jasonwynn10 Moderator Poggit Reviewer

    Messages:
    1,489
    GitHub:
    jasonwynn10
    seriously... If you don't bother to look at PocketMine's API before asking this, post in the facepalm section
     
    Kyd, EdwardHamHam and HimbeersaftLP like this.
  6. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
    If you have to ask a question line by line, why don't you just request a plugin :/
     
  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.