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

Give player full health

Comments in 'Plugin Development' started by jjmc, Dec 26, 2015.

  1. jjmc
    Offline

    jjmc New Member

    Joined:
    Oct 18, 2015
    Posts:
    41
    Hi,
    I'm trying to set a player's health to full on world change, my code:
    PHP:
    public function onEntityLevelChange(EntityLevelChangeEvent $event) {
        
    $entity $event->getEntity();
        
    $entity->setHealth(20);
    }
    I've tried setHealth() with 19, 20 and 21, but sometimes it fails, when I have about 5 hearts, it kills me, ...
    When I set setHealth() to 10, it always works, so I always have 5 hearts, but I want to give the player full health.
    How to do that correctly?
  2. jjmc
    Offline

    jjmc New Member

    Joined:
    Oct 18, 2015
    Posts:
    41
    Thanks, I've tried it but there's no function addHealth():
    Code:
    Fatal error: Call to undefined method pocketmine\Player::addHealth()
  3. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Wtf... Do not post if you can't even convince yourself that it is correct!

Share This Page

Advertisement