sure..
PHP Code:
public String getRankings(String job) {
try {
int int1 = 0;
int int2 = 0;
Connection con = DatabaseConnection.getConnection();
PreparedStatement ps = con.prepareStatement("SELECT * FROM characters WHERE job >= ? AND job <= ? AND gm = 0 ORDER BY level DESC LIMIT 10");
if (job.equals("warrior")) {
int1 = 100;
int2 = 132;
} else if (job.equals("magician")) {
int1 = 200;
int2 = 232;
} else if (job.equals("bowman")) {
int1 = 300;
int2 = 322;
} else if (job.equals("thief")) {
int1 = 400;
int2 = 422;
} else if (job.equals("pirate")) {
int1 = 500;
int2 = 522;
} else if (job.equals("beginner")) {
int1 = 0;
int2 = 0;
} else if (job.equals("me")) {
ps = con.prepareStatement("SELECT name FROM characters ORDER BY level DESC");
ResultSet rs = ps.executeQuery();
int i = 0;
int lol = 0;
while (rs.next()) {
i++;
if (rs.getString("name").equals(c.getPlayer().getName())) {
lol = i;
}
}
ps.close();
rs.close();
return ("Your current rank is: " + lol);
} else {
return "";
}
ps.setInt(1, int1);
ps.setInt(2, int2);
ResultSet rs = ps.executeQuery();
int i = 0;
String lulul = "";
while (rs.next()) {
i++;
lulul += (i + ") " + rs.getString("name") + ", level " + rs.getInt("level") + "\r\n");
}
ps.close();
rs.close();
return lulul;
} catch (SQLException e) {
return "Unknown error, please report this to the admin";
}
}
a npc script would be:
PHP Code:
var status = 0;
function start() {
status = -1;
action(1, 0, 0);
}
function action(mode, type, selection) {
if (mode == -1) {
cm.dispose();
} else {
if (mode == 0) {
cm.dispose();
return;
}
if (mode == 1)
status++;
else
status--;
if (status == 0) {
cm.sendYesNo("Hello there, do you want to check the rankings?");
} else if (status == 1) {
cm.sendSimple("Pick the job\r\n#b#L1#warrior#l\r\n#L2#magician#l\r\n#L3#bowman#l\r\n#L4#thief#l\r\n#L5#pirate#l\r\n#L6#beginner#l\r\n#L7#my own rank#l#k");
} else if (status == 2) {
var haha;
switch (selection) {
case 1:
haha = "warrior";
break;
case 2:
haha = "magician";
break;
case 3:
haha = "bowman";
break;
case 4:
haha = "thief";
break;
case 5:
haha = "pirate";
break;
case 6:
haha = "beginner";
break;
case 7:
haha = "me";
break;
default:
haha = "";
break;
}
cm.sendOk(cm.getRankings(haha));
cm.dispose();
} else {
cm.dispose();
}
}
}
This is untested, please tell me if it works
edit:
Its confirmed, it fully works, 100%!