- Joined
- Jan 21, 2009
- Messages
- 162
- Reaction score
- 1
MapleClient.javur
MapleCharacter.javur
CreateCharHandler.javur
UseCashItemHandler.javur
Make an SQL Query to add the field "charlimit" to `accounts`
Code:
public static int countCharacters(int aid) {
Connection con = DatabaseConnection.getConnection();
int ret = 0;
try {
PreparedStatement ps = con.prepareStatement("SELECT * FROM characters WHERE accountid = ?");
ps.setInt(1, aid);
ResultSet rs = ps.executeQuery();
rs.last(); // Last Row now
ret = rs.getRow(); // ID of last row = amount of rows.
ps.close();
} catch(SQLException sqle) {}
return ret;
}
MapleCharacter.javur
Code:
public static void increaseCharacterLimit(int aid, int inc) {
Connection con = DatabaseConnection.getConnection();
try {
PreparedStatement ps = con.prepareStatement("UPDATE accounts SET charlimit = charlimit + ? WHERE id = ?");
ps.setInt(1, inc);
ps.setInt(2, aid);
ps.executeUpdate();
ps.close();
} catch (SQLException s) {}
}
public static int getCharacterLimit(int aid, boolean SQL) {
int ret = 0;
if (SQL) {
Connection con = DatabaseConnection.getConnection();
try {
PreparedStatement ps = con.prepareStatement("SELECT * FROM accounts WHERE id = ?");
ps.setInt(1, aid);
ResultSet rs = ps.executeQuery();
ret = rs.getInt("charlimit");
ps.close();
} catch (SQLException sqle) {}
} else {
// TODO Make a List.
}
if (ret > 6)
return 6; // 6 is max.
return ret;
}
CreateCharHandler.javur
Code:
if (MapleCharacter.getCharacterLimit(c.getAccID(), true) <= c.countCharacters(c.getAccID())) {
charok = false;
}
UseCashItemHandler.javur
Code:
else if (itemType == 543) {
c.getPlayer().increaseCharacterLimit(c.getAccID(), 1);
MapleInventoryManipulator.removeById(c, MapleInventoryType.CASH, 5430000, 1, true, false);
}
Make an SQL Query to add the field "charlimit" to `accounts`