rebirth ranking in game.

Status
Not open for further replies.
Experienced Elementalist
Joined
May 29, 2008
Messages
241
Reaction score
0
ok i dont take credits for this. i took the base code from somewhere else whoever is that credits go to him.

EDIT: CREDITS TO gorgon0 for base code

ok so go to commandprocessor.java and find:

Code:
else {
				mc.dropMessage("GM Command " + splitted[0] + " does not exist");
			}

and add this before the 'else' :
Code:
else if (splitted[0].equals("@reborns")) {
             ResultSet rs = reborns();
                           try { mc.dropMessage("Reborn Ranking Top 10:");
                               while(rs.next()){
                                  
                                  mc.dropMessage("Player : " + rs.getString("name") + "        |      Reborns :" + rs.getInt("reborns"));
                               }
                            } catch(Exception ex) {}
                        
	}
You can change the @reborns to anything you like for the command.

then find this:
Code:
private static String getCharInfoById(int id){
                        try {
            Connection dcon = DatabaseConnection.getConnection();
            PreparedStatement ps = dcon.prepareStatement("SELECT * FROM characters where id = ?");
            ps.setInt(1, id);
            ResultSet rs = ps.executeQuery();
            if(rs.next())
            return rs.getString("name");
            
            } catch(Exception ex) {}
            return "error while trying to get name";
            
        }

add t his below:
Code:
public static ResultSet reborns() {		
		try {
			Connection con = DatabaseConnection.getConnection(); 
			PreparedStatement ps = con.prepareStatement("SELECT name,reborns FROM characters WHERE gm = 0 ORDER BY reborns desc LIMIT 10");
                     return ps.executeQuery();
                     
		} catch (Exception ex) {}
			
		return null;
	}

then compile and you're done. works 100%. it shows the top 10 reborn ranks.
 
Last edited:
Re: [Small RELEASE] rebirth ranking in game.

hmm kind of a noob question. the column in my database says rebirth, could we just change the result set from reborn to rebirth?
 
Re: [RELEASE] rebirth ranking in game.

i know im kinda like.. bumping.. so.. yeah, i was wondering, there isnt anything in commandproccessor.java with that, so.. how do I do it? im using ThePack repack v62, help?
 
Re: [RELEASE] rebirth ranking in game.

then find this:
Code:
private static String getCharInfoById(int id){
                        try {
            Connection dcon = DatabaseConnection.getConnection();
            PreparedStatement ps = dcon.prepareStatement("SELECT * FROM characters where id = ?");
            ps.setInt(1, id);
            ResultSet rs = ps.executeQuery();
            if(rs.next())
            return rs.getString("name");
            
            } catch(Exception ex) {}
            return "error while trying to get name";
            
        }

add t his below:
Code:
public static ResultSet reborns() {		
		try {
			Connection con = DatabaseConnection.getConnection(); 
			PreparedStatement ps = con.prepareStatement("SELECT name,reborns FROM characters WHERE gm = 0 ORDER BY reborns desc LIMIT 10");
                     return ps.executeQuery();
                     
		} catch (Exception ex) {}
			
		return null;
	}

Where to put this?
 
Status
Not open for further replies.
Back