Bit stuck Could use some help

Discussion in 'Plugin Development' started by GrimReaper160490, Mar 2, 2011.

Thread Status:
Not open for further replies.
  1. I know this will sound stupid but, How do you

    make an announcement to the whole server upon a players death?

    saying " Player Name " Died " Reason "
    im just very confused about how to do this.

    is it just a simple Printlineevent tied to playernames? or something else.

    help would be appreciated
     
  2. Offline

    Edward Hand

    use:
    Code:
    theServer.broadcastMessage("some message");
    (replace 'theServer' with a reference to the server)
     
  3. Dont i have to use any Damage Events? so the plugin knows which player died?

    and with reference to the server you mean

    The servers name like MYServer or MCGC? Man i need coffee my brains not working properly right now.
    if you arent busy could you possibly help me out? just want a simple plugin that announces a Players death.

    i.e grimreaper160490 was blown away by a creeper / grimreaper160490 fell to his death!!

    if you could PM me your msn or Ill contect you though PM.

    cheers sorry i am New to Java Plugin Development i mean werent we all?
     
  4. Offline

    Edward Hand

    Code:
    public void onEntityDamage(EntityDamageEvent event)
    {
        event.getPlayer().getServer().broadcastMessage(event.getPlayer().getName()+ " has died");
    }
     
  5. Thank You Edward!

    Much appreciated

    After i placed that code into the Playerlistener? Class
    GetPlayer is underlined error saying GetPlayer() is undefined in entity damage so what variable or constructor need i build for getplayer?

    Sorry again but your a great help!
    Btw im from england to whereabouts your from?
     
  6. Offline

    Edward Hand

    Oops. I guess that's what happens when you try coding 5 minutes after you wake up. Here is a corrected version:
    Code:
    public class myListener extends EntityListener
    {
        public void onEntityDeath(EntityDeathEvent event)
        {
            if(event.getEntity() instanceof Player)
            {
                Player player = (Player)event.getEntity();
                player.getServer().broadcastMessage(player.getName()+" has died")
            }
        }
    }
    (and I'm from England too)
     
Thread Status:
Not open for further replies.

Share This Page