Help Scoreboard

Discussion in 'Spigot Plugin Development' started by Skud31, May 3, 2015.

  1. Hi guys,
    I'm here because I'm making a plugin and I need to know how I can have a counter of
    -Number of deaths
    -Number of kills
    -Ratio
    This 3 stats on 1 SB
    thanks for your help
    EDIT: Sorry for my bad english :3
     
  2. Please show some effort first. You'll be more likely to find developers to help you if you first search Google yourself, and at least attempt what you're trying to do before asking for others to do it for you and just copy & paste into your IDE.
     
  3. public void setPlayerBoard(Player player)
    {
    ScoreboardManager mang = Bukkit.getScoreboardManager();
    Scoreboard board = mang.getNewScoreboard();
    Objective objective = board.registerNewObjective("Stats", "dummy");
    objective.setDisplaySlot(DisplaySlot.SIDEBAR);
    objective.setDisplayName(ChatColor.BLUE + "Your Stats");

    Score kills = objective.getScore(Bukkit.getOfflinePlayer("Kills: " ));
    Score deaths = objective.getScore(Bukkit.getOfflinePlayer("Deaths: " ));

    TestPlayer play = pg.track.getPlayerData(player);
    TestScore values = play.getScore();
    score.setScore(values.getTotalScore());
    kills.setScore(values.getKills());
    deaths.setScore(values.getDeaths());
    player.setScoreboard(board);
    scoreTimer(player);
    }



    this should guide you for some part use it as a base
     
  4. Make a scoreboard, take the number of deaths with the "PlayerDeathEvent", you can take the kills with the "PlayerDeathEvent" taking the killer and updating the scoreboard.

    EDIT: You can update the scoreboard, with a Runnable.
     
    #4 NahuLD, May 4, 2015
    Last edited: May 4, 2015
  5. public static double getKdr(PvpPlayer pp) {
    int kills = pp.getKills();
    int deaths = pp.getDeaths();
    if(kills == 0 && deaths == 0)
    return 1;
    else if(kills > 0 && deaths == 0) {
    return kills;
    } else if(deaths > 0 && kills == 0) {
    return deaths;
    } else {
    return MathUtil.round(kills / (double) deaths, 2);
    }
    }


    use that to get KDR/ratio

    (Script found in pvplevels - https://github.com/Supermaxman/PvpL...s/src/com/lenis0012/bukkit/pvp/PvpLevels.java)
     
  6. There are plenty of scoreboard tutorials on YouTube.
     
  7. Thanks guy's I'll test this after.
     
  8. I don't understand this part, someone can help me please :(
     
  9. that was just an example of stuff let me get a better one hold on
     
  10. Why are you spoon feeding and spoon feeding without knowing what you are doing?