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

small problem that I do not see xD

Comments in 'Plugin Development' started by Praxthisnovcht, Jan 15, 2015.

  1. Praxthisnovcht
    Offline

    Praxthisnovcht Notable Member Plugin Developer

    Joined:
    Mar 10, 2014
    Posts:
    701
    Plugins:
    4
    Minecraft User:
    PraxHellTag
    Code:
    Parse error: syntax error, unexpected '::'
    PHP:
                if ($item->getID () == Item:: Item::STONE_SWORDItem::DIAMOND_BOOTSItem::IRON_LEGGINGSItem::RAW_CHICKENItem::GOLD_CHESTPLATEItem::IRON_HELMET#Lines error
                    
    return;
            }
            
    $player->getInventory ()->addItem Item::get Item:: Item::STONE_SWORDItem::DIAMOND_BOOTSItem::IRON_LEGGINGSItem::RAW_CHICKENItem::GOLD_CHESTPLATEItem::IRON_HELMET ) );
        }
  2. iksaku
    Offline

    iksaku Notable Member Plugin Developer

    Joined:
    Sep 2, 2013
    Posts:
    1,130
    Plugins:
    4
    Minecraft User:
    iksaku
    Remove the empty 'Item:: ' xD
    This is the modified version:
    PHP:
         if ($item->getID () == Item::STONE_SWORDItem::DIAMOND_BOOTSItem::IRON_LEGGINGSItem::RAW_CHICKENItem::GOLD_CHESTPLATEItem::IRON_HELMET){ #Lines error
              
    return;
         }
         
    $player->getInventory ()->addItem Item::get Item:: Item::STONE_SWORDItem::DIAMOND_BOOTSItem::IRON_LEGGINGSItem::RAW_CHICKENItem::GOLD_CHESTPLATEItem::IRON_HELMET ) );
    }
    Ooops, edited xD
  3. Praxthisnovcht
    Offline

    Praxthisnovcht Notable Member Plugin Developer

    Joined:
    Mar 10, 2014
    Posts:
    701
    Plugins:
    4
    Minecraft User:
    PraxHellTag
    xD me looking complicated
    Thank you!
  4. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,306
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Still wrong. What is if($id == $id1, $id2, $id3){}?
  5. Praxthisnovcht
    Offline

    Praxthisnovcht Notable Member Plugin Developer

    Joined:
    Mar 10, 2014
    Posts:
    701
    Plugins:
    4
    Minecraft User:
    PraxHellTag
    public function onJoin(PlayerJoinEvent $event) {
    $player = $event->Player ();
    foreach ( $player->getInventory ()->getContents () as $item ) {
    if ($item->getID () == Item (Item::STONE_SWORD, Item::DIAMOND_BOOTS, Item::IRON_LEGGINGS, Item::RAW_CHICKEN, Item::GOLD_CHESTPLATE, Item::IRON_HELMET)
    return;
    }
  6. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,306
    Plugins:
    11
    Minecraft User:
    PEMapModder
    You sure?
  7. xpyctum
    Offline

    xpyctum Active Member Plugin Developer

    Joined:
    Jan 13, 2014
    Posts:
    292
    Plugins:
    4
    Minecraft User:
    tylerdisney
    PHP:
    public function onJoin(PlayerJoinEvent $event) {
       
    $player $event->getPlayer();
       foreach ( 
    $player->getInventory ()->getContents () as $item ) {
          if(
    $item->getID () == Item::STONE_SWORD and $item->getID () == Item::DIAMOND_BOOTS and $item->getID () == Item::IRON_LEGGINGS and $item->getID () == Item::RAW_CHICKEN and Item::GOLD_CHESTPLATE and $item->getID () == Item::IRON_HELMET)
                    return;
    }
    Last edited: Jan 17, 2015
  8. Praxthisnovcht
    Offline

    Praxthisnovcht Notable Member Plugin Developer

    Joined:
    Mar 10, 2014
    Posts:
    701
    Plugins:
    4
    Minecraft User:
    PraxHellTag
    not exactly: D

    Thank you! I'll try
    Last edited: Jan 16, 2015
  9. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,306
    Plugins:
    11
    Minecraft User:
    PEMapModder
    $event->getPlayer();
    xpyctum likes this.
  10. Praxthisnovcht
    Offline

    Praxthisnovcht Notable Member Plugin Developer

    Joined:
    Mar 10, 2014
    Posts:
    701
    Plugins:
    4
    Minecraft User:
    PraxHellTag
    it is possible to add several item?

    PHP:
    public function onJoin(PlayerJoinEvent $event) {
       
    $player $event->getPlayer();
       foreach ( 
    $player->getInventory ()->getContents () as $item ) {
          if(
    $item->getID () == Item::STONE_SWORD and $item->getID () == Item::DIAMOND_BOOTS and $item->getID () == Item::IRON_LEGGINGS and $item->getID () == Item::RAW_CHICKEN and Item::GOLD_CHESTPLATE and $item->getID () == Item::IRON_HELMET)
                    return;
    }
    Last edited: Jan 17, 2015
  11. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,306
    Plugins:
    11
    Minecraft User:
    PEMapModder
    PHP:
    if($id === or $id === or $id === 3){ do something... }
  12. Praxthisnovcht
    Offline

    Praxthisnovcht Notable Member Plugin Developer

    Joined:
    Mar 10, 2014
    Posts:
    701
    Plugins:
    4
    Minecraft User:
    PraxHellTag
    You are awesome !
    Thank
  13. iksaku
    Offline

    iksaku Notable Member Plugin Developer

    Joined:
    Sep 2, 2013
    Posts:
    1,130
    Plugins:
    4
    Minecraft User:
    iksaku
    Never use commas (,) inside if/else statements :p they're used most in for loops
    Praxthisnovcht likes this.
  14. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,306
    Plugins:
    11
    Minecraft User:
    PEMapModder
    They're semicolons.
    And you may use them to separate params.
    ;)
    Praxthisnovcht likes this.
  15. iksaku
    Offline

    iksaku Notable Member Plugin Developer

    Joined:
    Sep 2, 2013
    Posts:
    1,130
    Plugins:
    4
    Minecraft User:
    iksaku
    But inside the second parameter (the evaluate part, after the first semicolon) you can evaluate multiple things by separating them using a comma

Share This Page

Advertisement