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

Code don't work

Comments in 'Plugin Development' started by KekerFamily, Dec 27, 2015.

  1. KekerFamily
    Offline

    KekerFamily New Member

    Joined:
    Nov 12, 2015
    Posts:
    12
    Minecraft User:
    Keker
    Please help me :c
    My code not work
    public function KillRewards(PlayerDeathEvent $event){
    $player = $event->getPlayer();
    switch(mt_rand(0,3){
    case 1:
    $drops = [];
    $id = mt_rand(1,280);
    $count = mt_rand(3, 10);
    $drops[] = new Item($id, 0, $count);
    $event->setDrops($drops);
    break;
    case 2;
    $drops = [];
    $id = mt_rand(2,288);
    $count = mt_rand(3, 10);
    $drops[] = new Item($id, 0, $count);
    $event->setDrops($drops);
    break;
    case 3;
    $drops = [];
    $id = mt_rand(3,360);
    $count = mt_rand(3, 10);
    $drops[] = new Item($id, 0, $count);
    $event->setDrops($drops);
    break;
    }
    }
  2. AndrewBit
    Offline

    AndrewBit Notable Member

    Joined:
    Jun 18, 2015
    Posts:
    435
    Minecraft User:
    AndrewBit4
    Please, write your code inside
    Code:
    [ PHP] # code [ /PHP]
    
    tags
    KubixQ and CraftYourBukkit like this.
  3. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Use Item::get() instead of new Item(). Otherwise, it may cause certain items to not work properly.
    KekerFamily likes this.
  4. Nawaf_Craft1b
    Offline

    Nawaf_Craft1b Active Member Plugin Developer

    Joined:
    May 8, 2015
    Posts:
    232
    Plugins:
    1
    Minecraft User:
    Nawaf_Craft1b
    PHP:
    Public Function onDeath(PlayerDeathEvent $ev){
    $id 1;
    $count 1;
    $damage 0;

    switch(
    mt_rand(1,3)){
    Case 
    1:
    $ev->setDrops(array(Item::get($id,$damage,$count));
    Break
    Case 
    2:
    $ev->setDrops(array(Item::get(2,0,2));
    Break;
    Case 
    3:
    $ev->setDrops(array(Item::get(7,7,7));
    Break;
    }
    }
    Fix Code
    And USE
    [CODE ] #CODE [ /CODE]
    KekerFamily likes this.

Share This Page

Advertisement