Solved Pvp counter help

Discussion in 'Plugin Development' started by A4Papers, Jan 16, 2014.

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

    A4Papers

    Hi. I'm working on my plugin and I wanted to add a sign that displays the total amount of pvp kills on the server. If anyone knows the coding on how to do this it would be greatly appreciated .
    Thanks for the help.




    I'm looking for something like this.
    [​IMG]
     
  2. Offline

    NoLiver92

    when the player clicks the sign, get the username of the player and then the kills, once you got the kills update the sign with the number of kills the player has got. This should be fairly easy to do
     
  3. Offline

    A4Papers

    The problem i'm having is 'storing' the amount of players then have been killed. :(
    I'm quite new to this.
     
  4. Offline

    NoLiver92


    what about in the config file?
     
  5. Offline

    A4Papers

    NoLiver92 Store the total kills in the config? How would i do this?
     
  6. Offline

    NoLiver92


    This is one of the basic skills for a bukkit plugin developer and is contained in the plugin tutorial. here.

    I suggest you go through the tutorial before starting more complex plugins
     
  7. Offline

    Mattigins

    Code:java
    1. @EventHandler
    2. public void onPlayerDead (PlayerDeathEvent e) {
    3. if (e.getEntity() instanceof Player) {
    4. getConfig().set("pvpKills", plugin.getConfig().getInt("pvpKills") + 1);
    5. saveConfig();
    6. }
    7. }
     
    A4Papers likes this.
  8. Offline

    NoLiver92

    Mattigins ok, you have to have a key for each player otherwise all the players will have the same kill count.

    Code:java
    1. int kills = plugin.getConfig().getInt(e.getPlayer()+".pvpKills") + 1;
    2. getConfig().set(e.getPlayer()+".pvpKills", kills);


    this code will get the kills for each player and then set them. I also suggest when the player joins the server you make sure they are in the config, if not create them or youll get an error at this point. Read the tutorial and it will chow you the setup and hopefully you'll understand this.
     
    A4Papers likes this.
  9. Offline

    A4Papers

    Thanks all. :)
     
  10. Offline

    Mattigins

    That is all well and good but in his initial post he said he wanted to get the total pvp kills for the server.
     
  11. Offline

    NoLiver92

    Mattigins My mistake but knowing both is still useful.
     
    A4Papers likes this.
Thread Status:
Not open for further replies.

Share This Page