getting the last person to hit them

Discussion in 'Plugin Development' started by nitrousspark, Aug 28, 2012.

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

    nitrousspark

    i need to get the last person to hit someone when they die

    like i hit someone and they jump in lava but it still says i kill them
     
  2. Offline

    Linux1337

    uhh, any current code? if you have code please post it here else please post in the plugin req part of the forums
     
  3. Offline

    travja

    Just log what they were damaged by as they get hurt, when they finally die, go up from the bottom of the list and when you hit something that is a player, that is the person that hit them last. So your list would look something like:
    nitrousspark:
    - DROWNING
    - ARROW
    - Player_travja
    - FIRE

    Your code for the check would be EntityDamageEvent and use something like this
    Code:java
    1. if(p.getDamager() instanceof Player){
    2. List damages = config.getStringList(p.getName());
    3. damages.add("Player_" + ((Player)p.getDamager()).getName());
    4. config.getStringList(p.getName()).set(damages); //not quite sure here...
    5. saveConfig();
    6. }else if(p.getDamager() instaceof EntityDamageEvent.EntityAttack){
    7. //same as above but just mob attack or something...
    8. }else if(p.getDamager() instanceof ..... // and so on, just do it to your liking!
    9.  
    10. }
     
  4. Offline

    Barinade

    EntityDamageEvent, if entity is a player, continue
    If damage cause is not from a player, continue
    if last damage cause is from a player, continue
    damage player according to event
    cancel event

    Sumping liek dis?
     
  5. Offline

    honestduane

    If you have that ability - to look at damage and see what player damaged them last - wouldn't it be easier and faster to keep a global Hashmap<string, string> around and update it every time the user was damage by another player, then on death look for the users name in the map (Players being damaged are keys, the player damaging them are values) and use that to get the details for the players death?
     
Thread Status:
Not open for further replies.

Share This Page