How to get when a player actually gets hit.

Discussion in 'Plugin Development' started by goomonster3, Feb 20, 2014.

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

    goomonster3

    Hi,
    What im trying to do is the following: When you hit a player it adds 3 more durability points onto the player you hit's armor. So, if I spam click it adds tons of points on, eventually breaking the armor very fast.
    How can I check when the player actually gets hit, not when they get clicked(macro users can break the armor in less than 10 seconds)

    No, an EntityDamageByEntityEvent doesn't get when they are actually hit, that gets when they are clicked

    Thanks,
    Goo
     
  2. Offline

    IkBenHarm

  3. Offline

    goomonster3

    That isn't an event
     
  4. Offline

    MOMOTHEREAL

    EntityDamageByEntityEvent does not get fired when they get 'clicked' (thats EntityInteractEvent), its when an Entity (e.getEntity()) gets damaged by another Entity (e.getDamager()). Then you can check if the entities are instance of a Player.

    You can also try EntityDamageEvent.
     
  5. Offline

    goomonster3

    EntityDamageByEntityEvent does get when they get clicked, like left clicked. If I use a macro and use the ability it breaks the armor much faster
     
  6. Offline

    MOMOTHEREAL

  7. Offline

    DoctorDark

    Try checking if the event damage is more than 0
     
  8. Check if the damage is greater than 0, if so add it to the armour.
     
  9. Offline

    IkBenHarm

    goomonster3
    oh i indeed meant EntityDamageByEntityEvent
     
  10. Offline

    Garris0n

    Save the last time they were hit in milliseconds in a map and then check against that so you can limit it to, say, once every second. Also, perhaps you should look into an anticheat plugin if you have issues with macro users?
     
  11. Offline

    goomonster3

    Thanks, Solved. I used this method in the end
     
Thread Status:
Not open for further replies.

Share This Page