Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Help Anyone?

Comments in 'Plugin Development' started by TryoneLegendZzz, Jul 22, 2015.

  1. TryoneLegendZzz
    Offline

    TryoneLegendZzz Active Member

    Joined:
    May 31, 2015
    Posts:
    201
    Minecraft User:
    SavionLegendZzz
    Ok This Is My Second Time Posting This First Wasnt Very Helpful (cause i am a n00b) I Am Making A Crate Keys Plugin And When I Tap The Chest With The Item It Gives Me Stone Instead Of The Items I Set It To Give
    PHP:
    public function crateKeys(PlayerInteractEvent $event) {
    $player $event->getPlayer();
        
    $block $event->getBlock();
        if(
    $block->getId() == 54 && !$event->isCancelled()) {
            if(
    $player->getInventory()->getItemInHand()->getId() == 50) {
                
    $prizes = array(Item::get(Item::DIAMOND_CHESTPLATE,0,1),(Item::get(Item::DIAMOND_BLOCK,0,5)));  
                  
    $player->getInventory()->addItem(Item::get($prizes));
                
    $player->sendMessage("Items Added Into Your Inventory");
                
    $player->getInventory()->removeItem(item::get(5001));
                
    $event->setCancelled(true);
            }
            else {
                
    $player->sendMessage("You Need A Crate Key To Open The Crate!");
                
    $event->setCancelled(true);
            }
        }
        elseif(!
    $event->isCancelled()) {
            
    $event->setCancelled(false);
        }
    }
  2. MCPEPIG
    Offline

    MCPEPIG Notable Member

    Joined:
    Jun 22, 2014
    Posts:
    349
    Minecraft User:
    MCPEPIG
    Try this:
    PHP:
    foreach($prizes as $prize){
         
    $player->getInventory()->addItem($prize);
    }
    NOTE: It hasn't been tested, so I don't know if it'll work or not.
    TryoneLegendZzz likes this.
  3. TryoneLegendZzz
    Offline

    TryoneLegendZzz Active Member

    Joined:
    May 31, 2015
    Posts:
    201
    Minecraft User:
    SavionLegendZzz
    Yeah But The Thing That Is Messed Up Is The Prize Giving :p
  4. TryoneLegendZzz
    Offline

    TryoneLegendZzz Active Member

    Joined:
    May 31, 2015
    Posts:
    201
    Minecraft User:
    SavionLegendZzz
    This Worked Thanks!
  5. MCPEPIG
    Offline

    MCPEPIG Notable Member

    Joined:
    Jun 22, 2014
    Posts:
    349
    Minecraft User:
    MCPEPIG
    Np

Share This Page

Advertisement