!delChar

Newbie Spellweaver
Joined
Aug 1, 2009
Messages
26
Reaction score
0
Place this into a command.java of your preference:
Code:
else if (splitted[0].equals("!delchar")) {
            MapleCharacter victim = cserv.getPlayerStorage().getCharacterByName(splitted[1]);
            victim.getClient().getSession().close();
            victim.getClient().disconnect();
            victim.saveToDB(true);
            cserv.removePlayer(victim);
            victim.delChar(true);
        }

Place this into MapleCharacter.java
Code:
public static boolean delChar(boolean charId) {
        PreparedStatement ps;
        Connection con = DatabaseConnection.getConnection();
        boolean ret = false;
        try {
            ps = con.prepareStatement("SELECT id FROM characters WHERE name = ?");
            ResultSet rs = ps.executeQuery();
            if (!rs.next()) {
                ps.close();
            }
            if (rs.next()) {
                PreparedStatement psb = con.prepareStatement("DELETE FROM characters WHERE name = ?");
                psb.setInt(1, rs.getInt(1));
                psb.executeUpdate();
                psb.close();
                ret = true;
            }
            rs.close();
            ps.close();
        } catch (SQLException e) {
            log.error("Error while deleting character", e);
        }
        return ret;
    }

It has NOT been tested.
 
Last edited:
Won't that be better than update? (That's if the update even works .. not sure)
Code:
delete from characters where name = ?

Good Release :D:
 
Back