PDA

View Full Version : [317] KDR rounding



Kingdomkey01
June 10th, 2011, 02:47
This takes your KDR command and cuts off any numbers after the hundredths place.
Before:
"My KDR is: 0.3427987234"

After:
"My KDR is 0.34"

This is the command that I use



if (cmd.equalsIgnoreCase("kdr") || cmd.equalsIgnoreCase("ratio")) {
DecimalFormat df = new DecimalFormat("#.##");
double ratio = ((double) c.pkPoints) / ((double) c.deathPoints);
c.say("My KDR is: " + df.format(ratio) + "");
}


Change the red to your own PKpoints and death points.

Add this import:



import java.text.DecimalFormat;

Javastrong
June 13th, 2011, 17:28
this is nice

Paradox68
July 27th, 2011, 13:42
Hey um, How do I get the DecimalFormat.text file? I want to do this with my server but don't have that file to import in my client class.