[Help] GetHealt() help

Discussion in 'Plugin Development' started by LordManegane, Jul 8, 2013.

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

    LordManegane

    Well i try this.
    But doesnt work.

    target.setHealth(target.getPlayer().getHealth()-4);
     
  2. Offline

    ERROR372

    LordManegane

    try:

    Code:
    target.setHealth((double)(target.getPlayer().getHealth())-4.0)
     
  3. Offline

    LordManegane

  4. Offline

    adam753

    Show the error please.
     
  5. Offline

    LordManegane

    target.setHealth(target.getPlayer().getHealth()-4);
    Error in getHealth
    It says: The method getHealth() its ambigus for the type player
     
  6. Offline

    adam753

  7. Offline

    LordManegane

    I try it but i cant
     
  8. Offline

    AmShaegar

  9. Offline

    ERROR372

    LordManegane

    Wait...

    target.setHealth(target.getPlayer().getHealth()-4);

    What is target? Player? String?
     
  10. Offline

    LordManegane

    Its the player
     
  11. Offline

    ERROR372

    So why do you do target.getPlayer()? You already have the player...

    what happens if you do target.setHealth(target.getHealth() - 4); ?
     
  12. Offline

    adam753

  13. Offline

    ERROR372

    adam753

    He's also doing it wrong. He does Player.Player.getHealth() essentially... that's wrong.

    He needs to just do "target.setHealth((double)target.getHealth - 4.0);"

    If I do the above code I provided, I have no issues at all.
     
  14. Offline

    adam753

    Using the newest CraftBukkit version?
     
  15. Offline

    ERROR372

    adam753

    Yup. Keeping up with the dev builds.

    Don't ask me, I seem to be able to do things others can't (like replacing jars while the server is running it) =P
     
Thread Status:
Not open for further replies.

Share This Page