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!

[Release] Proper @rebirth command ! MUST SEE !

Experienced Elementalist
Joined
Jul 26, 2008
Messages
280
Reaction score
0
Greetings to all, once again. Here is the proper @rebirth command that I have made. Unlike the old one, this updates the reborns column in your database. Credits goes to me for making this & some to the person who made the old version too. Some credits to airflow0 for the rebirth function.

- Reborns Function *IMPORTANT* - (Must add this first)
Open MapleCharacter.java.
Ctrl + F and search for :
Code:
private int level;
Under it, add :
Code:
private int reborns;
Ctrl + F and search for :
Code:
ret.level = rs.getInt("level");
Under it add :
Code:
ret.reborns = rs.getInt("reborns");
Ctrl + F and search for :
Code:
ret.level = 1;
Under it add :
Code:
ret.reborns = 0;
Ctrl + F and find something that looks like this, it may be slightly different but just use some logic and apply it.
Code:
if (update) {
				ps = con.prepareStatement("UPDATE characters "
					+ "SET level = ?, fame = ?, str = ?, dex = ?, luk = ?, `int` = ?, "
					+ "exp = ?, hp = ?, mp = ?, maxhp = ?, maxmp = ?, sp = ?, ap = ?, "
					+ "gm = ?, skincolor = ?, gender = ?, job = ?, hair = ?, face = ?, map = ?, "
					+ "meso = ?, hpApUsed = ?, mpApUsed = ?, spawnpoint = ?, party = ?, buddyCapacity = ?, messengerid = ?, [B][U]messengerposition = ?,[/U][/B] pvpkills = ?, pvpdeaths = ? WHERE id = ?");
			} else {
                            //31 inserts
				ps = con
					.prepareStatement("INSERT INTO characters ("
						+ "level, fame, str, dex, luk, `int`, exp, hp, mp, "
						+ "maxhp, maxmp, sp, ap, gm, skincolor, gender, job, hair, face, map, meso, hpApUsed, mpApUsed, spawnpoint, party, buddyCapacity, messengerid, [B][U]messengerposition,[/U][/B] pvpkills, pvpdeaths, accountid, name, world"
						+ ") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
			}
After the first bolded part, add in
Code:
, reborns = ?,
After the second bolded part, add in
Code:
 reborns,
After the last '?' in 'VALUES', add in an extra ', ?' without the ' '.
Ctrl + F and search :
Code:
ps.setInt(29, pvpkills);//pvp 
             ps.setInt(30, pvpdeaths);

			if (update) {
				ps.setInt(31, id);
			} else {
				ps.setInt(31, accountid);
                                ps.setString(32, name);
				ps.setInt(33, world); // TODO store world somewhere ;)
			}
Replace that with
Code:
ps.setInt(29, reborns);
ps.setInt(30, pvpkills);//pvp 
             ps.setInt(31, pvpdeaths);

			if (update) {
				ps.setInt(32, id);
			} else {
				ps.setInt(32, accountid);
                                ps.setString(33, name);
				ps.setInt(34, world); // TODO store world somewhere ;)
			}
Ctrl + F and search :
Code:
	public int getLevel() {
		return level;
	}
Under it add :
Code:
	public int getReborns() {
		return reborns;
	}
Finally, Ctrl + F and search :
Code:
public void setLevel(int level) {
                this.level = level-1;
        }
Under it add :
Code:
public void setReborns(int reborns) {
                this.reborns = reborns;
        }
Compile and you're done ! Although it looks long-winded, if you follow every step closely and apply some logic you should be able to get it done.

Now open CommandProcessor.java. Replace your old @rebirth command with this.
Code:
}	else if (splitted[0].equals("@rebirth")) {
                            int negexp;
                            if (c.getPlayer().getLevel() >= 200) {
                            c.getPlayer().setLevel(1);
                            c.getPlayer().setReborns(c.getPlayer().getReborns( ) + 1);
                            c.getPlayer().changeJob(MapleJob.getById(0));
                            
                            negexp = c.getPlayer().getExp();
                            c.getPlayer().gainExp(-negexp, false, false); // Fixes negative exp
		             c.getPlayer().updateSingleStat(MapleStat.EXP, c.getPlayer().getExp()); 

                            } else {
                                mc.dropMessage("Train harder and get to level 200.");
                            }
Lastly, check your characters table in your database if you have the column `reborns`. If not, run this sql.
Code:
ALTER TABLE `characters` ADD COLUMN `reborns` int(11) NOT NULL default '0' AFTER `messengerposition`
If you wanna use an npc to do rebirth instead of a command, use this. Full credits to airflow0 for this.
In NPCConversationManager.java, add this anywhere between 2 functions.
Code:
        public void doReborn() {
                if (getPlayer().getReborns() < MAX_REBORNS) {
                        getPlayer().setReborns(getPlayer().getReborns() + 1);
                        unequipEverything();
                        List<Pair<MapleStat, Integer>> reborn = new ArrayList<Pair<MapleStat, Integer>>(4);
                        getPlayer().setLevel(1);
                        getPlayer().setHp(50);
                        getPlayer().setMaxHP(50);
                        getPlayer().setMp(50);
                        getPlayer().setMaxMP(50);
                        getPlayer().setExp(0);
                        getPlayer().setRemainingSp(0);
                        getPlayer().setJob(MapleJob.BEGINNER);
                        reborn.add(new Pair<MapleStat, Integer>(MapleStat.LEVEL, Integer.valueOf(1)));
                        reborn.add(new Pair<MapleStat, Integer>(MapleStat.HP, Integer.valueOf(50)));
                        reborn.add(new Pair<MapleStat, Integer>(MapleStat.MP, Integer.valueOf(50)));
                        reborn.add(new Pair<MapleStat, Integer>(MapleStat.MAXHP, Integer.valueOf(50)));
                        reborn.add(new Pair<MapleStat, Integer>(MapleStat.MAXMP, Integer.valueOf(50)));
                        reborn.add(new Pair<MapleStat, Integer>(MapleStat.EXP, Integer.valueOf(0)));
                        reborn.add(new Pair<MapleStat, Integer>(MapleStat.AVAILABLESP, Integer.valueOf(0)));
                        reborn.add(new Pair<MapleStat, Integer>(MapleStat.JOB, Integer.valueOf(0)));
                        getPlayer().getClient().getSession().write(MaplePacketCreator.updatePlayerStats(reborn));
                        getPlayer().getClient().getSession().write(MaplePacketCreator.serverNotice(6, "You have been reborn!!"));
                        getPlayer().getMap().broadcastMessage(getPlayer(), MaplePacketCreator.showJobChange(getPlayer().getId()), false);
                } else {
                        getPlayer().getClient().getSession().write(MaplePacketCreator.serverNotice(6, "You have reached the maximum amount of rebirths!"));
                }
        }
Make sure you have these imports
Code:
import java.util.LinkedList;
import java.util.List;
import java.util.ArrayList;
import net.sf.odinms.client.MapleCharacter;
import net.sf.odinms.client.MapleJob;
import net.sf.odinms.client.MapleStat;
import net.sf.odinms.tools.Pair;
import net.sf.odinms.tools.MaplePacketCreator;
To set the max number of rebirths, add this
Code:
private final int MAX_REBORNS = [b]10[/b];
After this
Code:
private String getText;
Change the 10 to whatever you want for your max rebirths.

Now for the NPC script. Just add in cm.doReborn() in your rebirth npc. Example.
Code:
if (cm.getLevel() == 200) {
cm.doReborn();
As simple as that.
 
Last edited:
Experienced Elementalist
Joined
Jul 26, 2008
Messages
280
Reaction score
0
Oops I forgot to define player. Updated.
 
Supreme Arcanarch
Loyal Member
Joined
Jul 21, 2008
Messages
969
Reaction score
1
This is neat :)

Should i remove
Code:
ps.setInt(1, id);
?

I will have error for this part
 
Experienced Elementalist
Joined
Jul 26, 2008
Messages
280
Reaction score
0
This is neat :)

Should i remove
Code:
ps.setInt(1, id);
?

I will have error for this part
You'll need it to update the reborn column of the right id. What does the error say o_O?
 
Supreme Arcanarch
Loyal Member
Joined
Jul 21, 2008
Messages
969
Reaction score
1
cannot find symbol.
Symbol: Variable ID
location: class.net.odinms.client.messages.CommandProcessor

setInt(int,int) in java.sql.PreparedStatement cannot be applied to (int,id)
 
Experienced Elementalist
Joined
Jul 26, 2008
Messages
280
Reaction score
0
Hmm maybe I defined something earlier i'll go look for it first then i'll come back.
*Edit* Found it I forgot to define id. Hold on let me get it.
*Edit* Updated.
 
Experienced Elementalist
Joined
Jul 26, 2008
Messages
280
Reaction score
0
What's the command for getting character id o.o Is it
Code:
c.getPlayer().getCharacterById();
or
Code:
c.getPlayer().getCharInfoById();
Any idea? I forgot which..
*Edit* 90% Its the second one but help me test it thanks ^.^
 
Supreme Arcanarch
Loyal Member
Joined
Jul 21, 2008
Messages
969
Reaction score
1
Still not working it says incompatible types
 
Master Summoner
Loyal Member
Joined
Apr 20, 2008
Messages
578
Reaction score
76
Couldn't you just do

c.getPlayer().setReborns(c.getPlayer().getReborns() + 1);
 
Experienced Elementalist
Joined
Jul 26, 2008
Messages
280
Reaction score
0
Couldn't you just do

c.getPlayer().setReborns(c.getPlayer().getReborns() + 1);
Really? I couldn't find a getReborns method in MapleCharacter.java that's why I didn't use it. Or maybe I didn't add it. Idk. Alrite then i'll update it.
 
Supreme Arcanarch
Loyal Member
Joined
Jul 21, 2008
Messages
969
Reaction score
1
Still not working lol. I think i don't have the getreborns function in my MapleCharacter.java

EDIT: Compiled successful now testing XD
 
Junior Spellweaver
Joined
Jul 20, 2008
Messages
100
Reaction score
0
Pretty simple project to finish...

200th post!!
 
Back
Top