- Joined
- Apr 7, 2008
- Messages
- 100
- Reaction score
- 0
This is a function that can be called in NPCs to switch you job back to what it was before your rebirth, while keeping the same job rank (2nd, 3rd, or 4th). You need to have made your 2nd job advancement for this to work, because you job class would be lost in switching your job to a 1st job.A fix for that would be a new SQL column to store the class, but I'm not gonna do that because I like to save space.
1st, in your net.sf.odinms.client.MapleCharacter.java file, before the last }, or after
add this:
Next, run this SQL (You can make a .sql file if you want)
Then add this line to your rebirthing NPC before the job change happens.
and make sure that at the top of the NPC script, you have this import:
To switch you job back and forth, use these lines of code in your NPC:
You need a way to track rebirths for this to work. I am using my own way, but I don't wanna go through and get it. I believe airfl0w made a topic called Real reborn method that has instructions to add in a rebirth count to the database and allows you to see how many times you have been reborn. I'll go into more detail here if I need to.
1st, in your net.sf.odinms.client.MapleCharacter.java file, before the last }, or after
PHP:
public void setLevel(int level) {
this.level = level-1;
}
PHP:
public void switchjob(boolean set) {
// Made by FrozenLightning of RaGEZONE and CEF (FrozenLightningHacker on CEF)
int jobid = 0;
if(!set){ // Get the job to change to (only done when set is false)
Connection con = DatabaseConnection.getConnection();
try {
PreparedStatement ps = con.prepareStatement("SELECT rebirthjob FROM characters WHERE id = ?");
ps.setInt(1, id);
ResultSet rs = ps.executeQuery();
while (rs.next()) {
jobid = rs.getInt("rebirthjob");
}
ps.close();
rs.close();
} catch (SQLException se) {
log.error("SQL error: " + se.getLocalizedMessage(), se);
}
}
Connection con = DatabaseConnection.getConnection();
try { // Insert current job into the database
PreparedStatement ps = con.prepareStatement("UPDATE characters SET rebirthjob = ? WHERE id = ?");
ps.setInt(1, job.getId());
ps.setInt(2, id);
ps.execute();
ps.close();
} catch (SQLException se) {
log.error("SQL error: " + se.getLocalizedMessage(), se);
}
if(!set){
// Choose the correct job level
String jobto = Integer.toString(jobid); // Switch to a string
String current = Integer.toString(job.getId());
char[] arrto = jobto.toCharArray(); // Make an array
char[] arrcur = current.toCharArray();
arrto[2] = arrcur[2];
jobto = jobto.copyValueOf(arrto); // Turn the array into a string
jobid = Integer.parseInt(jobto); // Switch the string back to an int
// Change job without adding SP
this.job = MapleJob.getById(jobid);
updateSingleStat(MapleStat.JOB, jobid);
getMap().broadcastMessage(this, MaplePacketCreator.showJobChange(getId()), false);
silentPartyUpdate();
guildUpdate();
}
}
Next, run this SQL (You can make a .sql file if you want)
PHP:
ALTER TABLE characters ADD rebirthjob int(11) DEFAULT 0 AFTER job;
Then add this line to your rebirthing NPC before the job change happens.
PHP:
cm.getChar().switchjob(true);
PHP:
importPackage(net.sf.odinms.client);
PHP:
if (cm.getChar().getJob() != MapleJob.BEGINNER && cm.getChar().getJob() != MapleJob.WARRIOR && cm.getChar().getJob() != MapleJob.MAGICIAN && cm.getChar().getJob() != MapleJob.BOWMAN && cm.getChar().getJob() != MapleJob.THIEF){
cm.getChar().switchjob(false);
cm.sendOk("I have changed your job back!");
cm.dispose();}
Last edited: