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

Solved Soup-Kit

Comments in 'Plugin Development' started by TheBison_, Feb 28, 2016.

  1. TheBison_
    Offline

    TheBison_ New Member

    Joined:
    Mar 31, 2014
    Posts:
    46
    Minecraft User:
    TheBisonXD_
    If i use this code i dont get more Health and this sendMessage() function does not go too. Please help me to fix it.
    Code:
    use pocketmine\Player;
    use pocketmine\event\player\PlayerInteractEvent; 
    use pocketmine\item\Item;
    
            public function onSoup(PlayerInteractEvent $event)
            {
                $player = $event->getPlayer();
                $health = $player->getHealth();
                $item = $event->getItem();
                if($item->getId() === Item::get(282))
                {
                    $player->setHealth($health + 6);
                    $player->sendMessage("Debug");
                    $player->getInventory()->setItemInHand(new Item(Item::AIR,0,0));
                }
            }
  2. Hotshot_9930
    Offline

    Hotshot_9930 Notable Member Plugin Developer

    Joined:
    May 26, 2014
    Posts:
    665
    Plugins:
    2
    Minecraft User:
    HotshotHD
    Show full code.
    TheBison_ likes this.
  3. TheBison_
    Offline

    TheBison_ New Member

    Joined:
    Mar 31, 2014
    Posts:
    46
    Minecraft User:
    TheBisonXD_
  4. TheBison_
    Offline

    TheBison_ New Member

    Joined:
    Mar 31, 2014
    Posts:
    46
    Minecraft User:
    TheBisonXD_
    Its a Server System Plugin
  5. Hotshot_9930
    Offline

    Hotshot_9930 Notable Member Plugin Developer

    Joined:
    May 26, 2014
    Posts:
    665
    Plugins:
    2
    Minecraft User:
    HotshotHD
    Because its not very efficient only seeing part of the code. We don't even know if you registered events.
    Also show any errors the console might give.
    TheBison_ likes this.
  6. TheBison_
    Offline

    TheBison_ New Member

    Joined:
    Mar 31, 2014
    Posts:
    46
    Minecraft User:
    TheBisonXD_
    There are no errors and i have importet:
    use pocketmine\plugin\PluginBase;
    use pocketmine\utils\TextFormat as Color;
    use pocketmine\Player;
    use pocketmine\command\Command;
    use pocketmine\event\block\BlockPlaceEvent;
    use pocketmine\event\block\BlockBreakEvent;
    use pocketmine\event\Listener;
    use pocketmine\command\CommandSender;
    use pocketmine\event\block\SignChangeEvent;
    use pocketmine\event\player\PlayerInteractEvent;
    use pocketmine\level\Position;
    use pocketmine\tile\Sign;
    use pocketmine\event\entity\EntityDamageEvent;
    use pocketmine\event\player\PlayerDropItemEvent;
    use pocketmine\event\player\PlayerMoveEvent;
    use pocketmine\math\Vector3;
    use pocketmine\event\player\PlayerChatEvent;
    use pocketmine\event\player\PlayerLoginEvent;
    use pocketmine\event\player\PlayerKickEvent;
    use pocketmine\item\Item;
  7. Hotshot_9930
    Offline

    Hotshot_9930 Notable Member Plugin Developer

    Joined:
    May 26, 2014
    Posts:
    665
    Plugins:
    2
    Minecraft User:
    HotshotHD
    I just noticed that you are trying to compare an int and an Item object.
    Change:
    PHP:
    if($item->getId() === Item::get(282))
    // to:
    if($item->getId() === 282)
    Also learn the difference between == and ===
  8. TheBison_
    Offline

    TheBison_ New Member

    Joined:
    Mar 31, 2014
    Posts:
    46
    Minecraft User:
    TheBisonXD_
    It works now thanks :D
  9. TheBison_
    Offline

    TheBison_ New Member

    Joined:
    Mar 31, 2014
    Posts:
    46
    Minecraft User:
    TheBisonXD_
    $player->getInventory()->addItem((Item::get(ITEM::MUSHROOM_STEW))*64);

    do you know how i can write this?
  10. Hotshot_9930
    Offline

    Hotshot_9930 Notable Member Plugin Developer

    Joined:
    May 26, 2014
    Posts:
    665
    Plugins:
    2
    Minecraft User:
    HotshotHD
    PHP:
    $player->getInventory()->addItem(Item::get(Item::MUSHROOM_STEW060));
  11. TheBison_
    Offline

    TheBison_ New Member

    Joined:
    Mar 31, 2014
    Posts:
    46
    Minecraft User:
    TheBisonXD_
    Thanks! You are the best :)
    Hotshot_9930 likes this.

Share This Page

Advertisement