Add health instead of setting it

Discussion in 'Plugin Development' started by PwndahBear, Feb 12, 2013.

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

    PwndahBear

    Can someone tell me how I can let a player add health instead of having to set it using

    Code:
    player.setHealth(20);
     
  2. Offline

    danthonywalker

    player.setHealth(player.getHealth + whatever)
     
  3. Offline

    adam753

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

    PwndahBear

    Thanks :) But what if wanted to make the

    Code:
    player.setHealth(player.getHealth() + [COLOR=#ff0000]1[/COLOR]);
    any number a player types in?
     
  5. Offline

    adam753

  6. Offline

    danthonywalker

    Make a command, parse the arg string as an integer, catch any invalid exceptions, go from there.
     
  7. Offline

    PwndahBear

  8. Offline

    sniper_mine

    I get an error and it says getHealth() is ambiguous to a player.
    I'm using this exact code.
    Code:
        player.setHealth(player.getHealth() + 1);
     
  9. Offline

    Garris0n

    + 1D
     
  10. Offline

    sniper_mine

    Thanks so much!
     
  11. Offline

    _Filip

    PwndahBear
    Is it really this hard to use reasoning?
    You know you can get the players health.
    You know you can set it.

    Extremely basic logic is used finding the solution to the problem of not being able to add health.
     
Thread Status:
Not open for further replies.

Share This Page