[Release] Ingame Rankings

Status
Not open for further replies.
Joined
Apr 7, 2008
Messages
570
Reaction score
31
this is made by me
can be useful when a website is down or something..
enjoy

PHP:
} else if (splitted[0].equals("@ranking")) {
                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 (splitted.length == 1) {
                        mc.dropMessage("@ranking <job>, as job = warrior/magician/bowman/thief/pirate/beginner/me");
                        return;
                    } else if (splitted[1].equals("warrior")) {
                        int1 = 100;
                        int2 = 132;
                    } else if (splitted[1].equals("magician")) {
                        int1 = 200;
                        int2 = 232;
                    } else if (splitted[1].equals("bowman")) {
                        int1 = 300;
                        int2 = 322;
                    } else if (splitted[1].equals("thief")) {
                        int1 = 400;
                        int2 = 422;
                    } else if (splitted[1].equals("pirate")) {
                        int1 = 500;
                        int2 = 522;
                    } else if (splitted[1].equals("beginner")) {
                        int1 = 0;
                        int2 = 0;
                    } else if (splitted[1].equals("all")) {
                        int1 = 0;
                        int2 = 522;
                    } else if (splitted[1].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;
                            }
                        }
                        mc.dropMessage("You are currently ranked " + lol);
                        ps.close();
                        rs.close();
                        return;
                    } else {
                        mc.dropMessage("I don't recognize that job, make sure you use lower-case");
                        return;
                    }
                    ps.setInt(1, int1);
                    ps.setInt(2, int2);
                    ResultSet rs = ps.executeQuery();
                    int i = 0;
                    mc.dropMessage("These are the top 10 RageStory players:");
                    while (rs.next()) {
                        i++;
                        mc.dropMessage(i + ") " + rs.getString("name") + ", level " + rs.getInt("level"));
                    }
                    ps.close();
                    rs.close();
                } catch (SQLException e) {
                    mc.dropMessage("Unknown error, please report this to Bassoe");
                }

i might upload some screens..
 
Last edited:
sure..

PHP:
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:
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%!
 
Status
Not open for further replies.
Back