Set last damagecause

Discussion in 'Plugin Development' started by CraftBang, Jul 29, 2014.

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

    CraftBang

    Hello there, I've got a little problem.
    I got a game where people can kill eachother, but most people just suicide by jumping of the world!
    But I want them to be "killed" by the last person who hitted them (so maybe he shot him off)

    My Event to "kill" the player and set lastdamagecause.
    Code:
    @EventHandler
    public void onDamagereceiveEvent(EntityDamageEvent event){
    if(event.isCancelled()){
    return;
    }
    if(event.getCause().equals(DamageCause.VOID)){
    if((event.getEntity() instanceof Player)){
    event.setCancelled(true);
    EntityDamageEvent xd = event.getEntity().getLastDamageCause();
    ((Player) event.getEntity()).setHealth(0.0);
    event.getEntity().setLastDamageCause(xd);
    }
    }
    }
    
     
  2. Offline

    Garris0n

  3. Offline

    CraftBang

  4. Offline

    Jalau

    Just remove the lastDamagecause because if a player hit him like a few seconds before he will still be the killer, even if you set the health to 0 and kill him by magic, remember maybe the chat message like xx was killed by magic when trying to run from yy, thats a feature already, so you don't need to worry :) CraftBang
     
  5. Offline

    CraftBang

    ???
    If he jumps of the world my other code doesn't run that he got "killed" by the last player who hitted him...
     
  6. Offline

    CraftBang

    Jalau I don't really know what you mean.

    This is what happens :
    2 Players: A and B
    A hits B.
    B jumps of the world.
    A is NOT the killer, since B felled in the void.

    How do I make A the killer?
     
Thread Status:
Not open for further replies.

Share This Page