Gaining Health

Discussion in 'Plugin Development' started by cnniillaa, Jan 20, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    cnniillaa

    Hello i was wondering how to allow a player to "Gain" a certain amount of health.... This is what i am using right now but it sets there health to full.
    Code:
    player.setHealth(20);
    Is There anyway to allow the player to gain health?
     
  2. Offline

    Warreo

    cnniillaa Give them regeneration potion effect?
     
  3. Offline

    adam753

    Code:
    player.setHealth( player.getHealth() +1 );
    
     
  4. Offline

    cnniillaa

    Ok i did that and it says
    Here is the "Player" event i have ect.
    Code:
    Player player = event.getPlayer();
        player.sendMessage(ChatColor.WHITE + "[" + ChatColor.GOLD + "You Have Been healed!" + ChatColor.WHITE + "]");
        player.setHealth( player.getHealth () +10 );
     
  5. Offline

    sgavster

    do this:
    Code:java
    1. player.setHealth( player.getHealth () +10D );
     
  6. Offline

    cnniillaa

    i still get same error as last post i posted
     
  7. Offline

    sgavster

    try this..
    Code:java
    1. player.setHealth( (double)player.getHealth () +(double)10 );
     
  8. Offline

    cnniillaa

    Thanks for replying and nope i get the same error ?
     
  9. Offline

    _Cookie_

    Try:
    double d = player.getHealth();
    Player.setHealth(d + whatever);
     
  10. Offline

    Cirno

    You're referencing CB; if you have don't have to, reference Bukkit instead.
    Or:
    ((Damagable)player).setHealth(0D);
     
Thread Status:
Not open for further replies.

Share This Page