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

Add player health function...

Comments in 'Plugin Development' started by GetAway, Dec 9, 2015.

  1. GetAway
    Offline

    GetAway New Member

    Joined:
    Mar 26, 2015
    Posts:
    26
    Minecraft User:
    GetAway
    Hi.
    How to add hearts to player? Not max health... For example, 4 hearts to 6 hearts would be something like
    $player->addHealth(2)...
    Sorry I am sort of bad at this...
  2. Hotshot_9930
    Offline

    Hotshot_9930 Notable Member Plugin Developer

    Joined:
    May 26, 2014
    Posts:
    665
    Plugins:
    2
    Minecraft User:
    HotshotHD
    if i remember correctly, the setHealth() function is broken atm.
  3. GetAway
    Offline

    GetAway New Member

    Joined:
    Mar 26, 2015
    Posts:
    26
    Minecraft User:
    GetAway
    I see...
  4. GetAway
    Offline

    GetAway New Member

    Joined:
    Mar 26, 2015
    Posts:
    26
    Minecraft User:
    GetAway
    Nevermind I found it...
    Code:
    $player->setHealth($player->getHealth() + 8);
  5. minebuilder0110
    Offline

    minebuilder0110 Notable Member

    Joined:
    Dec 8, 2014
    Posts:
    485
    Minecraft User:
    Apparitional
    Talking about that, would it be possible to get around that by using potion effects?
  6. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    No.
  7. minebuilder0110
    Offline

    minebuilder0110 Notable Member

    Joined:
    Dec 8, 2014
    Posts:
    485
    Minecraft User:
    Apparitional
    Really? Huh.
  8. AndrewBit
    Offline

    AndrewBit Notable Member

    Joined:
    Jun 18, 2015
    Posts:
    435
    Minecraft User:
    AndrewBit4
    setHealth() is broken, no?
    You can "set" a fix health with:
    PHP:
    $x 1#The quantity of HP you want add to the player
    $p->addHealth($p->getHealth() - $p->getHealth $x);
    GetAway likes this.
  9. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    What are you even talking about XD. "set" a 'fix' health. Mind to elaborate?
  10. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    setHealth should be working well in my hunger pull request (check PocketMine pull requests) because I added attributes to it.
    GetAway and minebuilder0110 like this.

Share This Page

Advertisement