1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Solved Add health

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

  1. JarguarLoveMC

    JarguarLoveMC Spider Jockey

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

    wolfdale Zombie Pigman

    Messages:
    535
    GitHub:
    diamond-gold
    Do you mean healing or increasing the max health the player have?
     
  3. JarguarLoveMC

    JarguarLoveMC Spider Jockey

    Messages:
    49
    increasing the nmax health
     
  4. corytortoise

    corytortoise Skeleton

    Messages:
    825
    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 Spider Jockey

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

    KielKing Zombie

    Messages:
    245
    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);
     
  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.