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

setDrops()

Comments in 'Plugin Development' started by Hotshot_9930, Sep 27, 2015.

  1. Hotshot_9930
    Offline

    Hotshot_9930 Notable Member Plugin Developer

    Joined:
    May 26, 2014
    Posts:
    665
    Plugins:
    2
    Minecraft User:
    HotshotHD
    What is the correct way to use setDrops() when a player dies?
    Ive been doing:
    PHP:
    $event->setDrops(array(Item::get(266)));
    Im trying to make players drop Gold ingots when they die.
  2. Gamecrafter
    Offline

    Gamecrafter

    Joined:
    Nov 20, 2014
    Posts:
    978
    Plugins:
    9
    It's correct. :p
  3. Hotshot_9930
    Offline

    Hotshot_9930 Notable Member Plugin Developer

    Joined:
    May 26, 2014
    Posts:
    665
    Plugins:
    2
    Minecraft User:
    HotshotHD
    Oh Lol.
    I should have tested it before i posted this thread o_O
    Kvetinac97 likes this.
  4. zombie_Power
    Offline

    zombie_Power Active Member

    Joined:
    Sep 7, 2015
    Posts:
    239
    Minecraft User:
    Zombie_Power
    Greetings

    I am in a bit of trouble (decided to continue from this thread :p), So I just want to know that how can I get a random item from:
    PHP:
    $items = array(Item::get(26403), Item::get(26604), Item::get(26505), Item::get(38802));
                      
    $event->setDrops($items);
                
    I am not sure, but my idea is:
    PHP:
      return $items[array_rand($items1)];
    Any help appreciated :D
  5. Hotshot_9930
    Offline

    Hotshot_9930 Notable Member Plugin Developer

    Joined:
    May 26, 2014
    Posts:
    665
    Plugins:
    2
    Minecraft User:
    HotshotHD
    PHP:
    $randomItem array_rand($items1);
    $event->setDrops($randomItem);
    zombie_Power likes this.
  6. zombie_Power
    Offline

    zombie_Power Active Member

    Joined:
    Sep 7, 2015
    Posts:
    239
    Minecraft User:
    Zombie_Power
    Thanks :)
    Hotshot_9930 likes this.
  7. Hotshot_9930
    Offline

    Hotshot_9930 Notable Member Plugin Developer

    Joined:
    May 26, 2014
    Posts:
    665
    Plugins:
    2
    Minecraft User:
    HotshotHD
    No problem
    zombie_Power likes this.
  8. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
  9. MikkiMCPE
    Offline

    MikkiMCPE Active Member

    Joined:
    May 16, 2015
    Posts:
    125
    Minecraft User:
    MikkiMC
    did you was test it before?

    setDrops() must be an array, i want make it into array_rand too, but when player died, this function not working

    EDITED :rolleyes: IM SORRY :

    its working with this code :

    PHP:
    $items = array($item1$item2);
    $itemchance array_rand($items1);
    $drops = ($items[$itemchance]);
    $event->setDrops(array($drops));
    Last edited: May 24, 2016

Share This Page

Advertisement