Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

Swicth jobs back after rebirth

Junior Spellweaver
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
PHP:
        public void setLevel(int level) {
                this.level = level-1;
        }
add this:
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);
and make sure that at the top of the NPC script, you have this import:
PHP:
importPackage(net.sf.odinms.client);
To switch you job back and forth, use these lines of code in your NPC:
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();}
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.
 
Last edited:
Junior Spellweaver
Joined
Jul 19, 2008
Messages
151
Reaction score
0
Re: [RELEASE] Swicth jobs back after rebirth

nice, i was kind of waiting for this awhile back but as time went on I sort of didn't want it anymore. Although I won't be using this it's a nice release :D

edit: w00t first post ;D
 
Junior Spellweaver
Joined
May 26, 2008
Messages
195
Reaction score
0
Re: [RELEASE] Swicth jobs back after rebirth

This design works off 1 main job and taking sub jobs?

See this doesn't really help if someone has gone through 5 or so jobs then had a key wipe. :\
Then theyd only be able to recover there current job and first original job right? :\

And why would you need to track 1st jobs? or even 2nd,3rd.
Aslong as you jump to 4th you have all the books.
 
Junior Spellweaver
Joined
Apr 7, 2008
Messages
100
Reaction score
0
Re: [RELEASE] Swicth jobs back after rebirth

This design works off 1 main job and taking sub jobs?

See this doesn't really help if someone has gone through 5 or so jobs then had a key wipe. :\
Then theyd only be able to recover there current job and first original job right? :\

And why would you need to track 1st jobs? or even 2nd,3rd.
Aslong as you jump to 4th you have all the books.

its so you don't get your sp glitched. This is also based off of a 1 rebirth system. You can keep reusing it to get a diffrent sql row for more jobs.
 
Junior Spellweaver
Joined
May 26, 2008
Messages
195
Reaction score
0
Re: [RELEASE] Swicth jobs back after rebirth

I see, no one in my server has ever gotten an sp glitch. :\
I don't even know what it means.

But, even tho this is built for a 1 rebirth max server i still think its usefull.
You could just rebuild the npc to say
("You want to rebirth? In the case of a key wipe you will only be able to recover your current and last job keys")
("The job you are now will become your main job, if you would like to keep your last job as the main job please switch back now")
("So if your on your main job, would you like to be rebirthed?#L1#Yes#l#L2#No#l")

2 job's security is better then none right :p

And its useful for me because i wouldnt know how to set up a database that records each specific 4th job and make an npc read it :\
One day tho.
 
Legendary Battlemage
Joined
May 23, 2008
Messages
628
Reaction score
4
Re: [RELEASE] Swicth jobs back after rebirth

what is this suppose to do...
 
Junior Spellweaver
Joined
May 26, 2008
Messages
195
Reaction score
0
Re: [RELEASE] Swicth jobs back after rebirth

what is this suppose to do...

It's supposed to read and switch you back between your first 4th job and rebirth 4th job.

Was built for a 1 rebirth server.
 
Junior Spellweaver
Joined
Apr 7, 2008
Messages
100
Reaction score
0
Re: [RELEASE] Swicth jobs back after rebirth

It's supposed to read and switch you back between your first 4th job and rebirth 4th job.

Was built for a 1 rebirth server.

Auctually is only switched the jab and class. The level stays the same. So if you came from a 4th job IL and made a thief, who is currently a bandit, you will be switched to a 2nd job IL, not a 4th job one.
 
Junior Spellweaver
Joined
Apr 7, 2008
Messages
100
Reaction score
0
Re: [RELEASE] Swicth jobs back after rebirth

Whoops, forgot the SQL... Just added it.
 
Junior Spellweaver
Joined
May 20, 2008
Messages
153
Reaction score
0
Re: [RELEASE] Swicth jobs back after rebirth

Cool Nice Release!
 
Junior Spellweaver
Joined
May 26, 2008
Messages
195
Reaction score
0
Re: [RELEASE] Swicth jobs back after rebirth

Auctually is only switched the jab and class. The level stays the same. So if you came from a 4th job IL and made a thief, who is currently a bandit, you will be switched to a 2nd job IL, not a 4th job one.

I never said anything about level o.o
 
Initiate Mage
Joined
Jun 7, 2008
Messages
11
Reaction score
0
Re: [RELEASE] Swicth jobs back after rebirth

I really like this idea, people have been asking if this is possible or not so I guess now I can tell them it is. It looks as if you can only switch back to your previous job, which is still cool, if the players want to recover their skills at least they'll get one job back. I'll be sure to test this when I get some time.
 
Junior Spellweaver
Joined
Apr 7, 2008
Messages
100
Reaction score
0
Re: [RELEASE] Swicth jobs back after rebirth

If you want to add more jobs, just make a new MySQL column and add a function to get that one.
 
Elite Diviner
Joined
Jun 19, 2008
Messages
463
Reaction score
1
Re: [RELEASE] Swicth jobs back after rebirth

So what's the Ducking point to rebirth than ? To lvl fast and get AP/SP points ?
"Rebirth = Half This/Half That" :lol:

Call it something els, like ; Level1Leveler
 
Back
Top