Solved Add health

Discussion in 'Development' started by JarguarLoveMC, Dec 30, 2018.

  1. JarguarLoveMC

    JarguarLoveMC Silverfish

    Messages:
    23
    Hey how can i add health to players?
     
  2. wolfdale

    wolfdale Baby Zombie

    Messages:
    166
    Do you mean healing or increasing the max health the player have?
     
  3. JarguarLoveMC

    JarguarLoveMC Silverfish

    Messages:
    23
    increasing the nmax health
     
  4. corytortoise

    corytortoise Skeleton

    Messages:
    832
    GitHub:
    corytortoise
    Assuming you have a Player object, $player->setMaxHealth() should work. Keep in mind 20 should be the default max, with 1 equalling half of a heart. You may also need to use $player->setHealth(), since setting the max health won't necessarily set them to full health.
     
  5. JarguarLoveMC

    JarguarLoveMC Silverfish

    Messages:
    23
    what if i want to add 1 extra health on top of max health so this will equal to 11 health
     
  6. KielKing

    KielKing Silverfish

    Messages:
    20
    GitHub:
    kielking
    i'll make it short and simple
    PHP:
    /* @var Player $player */
    $addition 1// this equals to half a heart in minecraft // you can modify this value to anything you want
    $player->setMaxHealth($player->getMaxHealth() + $addition);
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.