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!

Hp and Mp Pouches for Pets!

Newbie Spellweaver
Joined
Mar 19, 2007
Messages
93
Reaction score
12
Ok after some simple coding here is the final result. keep in mind that since its all located in the movepethandler.java it only works when your pet moves, but it still works great! Edit: I used reindeer milk for the auto hp item, and sunset dew for the mp item. These are the only items that work with this, but you can change them to whatever you want.

In MovePetHandler.java

Find:
Code:
Boolean meso = false;

Add this after it:
Code:
Boolean hpp = false;
                Boolean mpp = false;
                MapleInventory use = player.getInventory(MapleInventoryType.USE);
                MapleItemInformationProvider mii = MapleItemInformationProvider.getInstance();

Next Find:
Code:
if (c.getPlayer().getInventory(MapleInventoryType.EQUIPPED).findById(1812000) != null)
                        meso = true;

Add this after it:
Code:
if (c.getPlayer().getInventory(MapleInventoryType.EQUIPPED).findById(1812002) != null)
                hpp = true;
                if (c.getPlayer().getInventory(MapleInventoryType.EQUIPPED).findById(1812003) != null)
                mpp = true;

Above the last two brackets at the bottom of the page, add:
Code:
if (hpp || mpp) {
                    if (hpp) {
                        if (player.getHp() < player.getAuto("hp"))
                                if (player.haveItem(2020013)) {
                                    MapleInventoryManipulator.removeById(c, MapleItemInformationProvider.getInstance().getInventoryType(2020013), 2020013, 1, true, false);
                                    mii.getItemEffect(2020013).applyTo(c.getPlayer());
                                }
                    }
                    
                    if (mpp) {
                        if (player.getMp() < player.getAuto("mp"))
                                if (player.haveItem(2020015)) {
                                    MapleInventoryManipulator.removeById(c, MapleItemInformationProvider.getInstance().getInventoryType(2020015), 2020015, 1, true, false);
                                    mii.getItemEffect(2020015).applyTo(c.getPlayer());
                                }
                    }
                    
                }

In MapleCharacter.java

Add this at the end of the page inside the last bracket:
Code:
public void setAuto(String type, int num) {
                ServernoticeMapleClientMessageCallback cm = new ServernoticeMapleClientMessageCallback(this.getClient());
        Connection con = DatabaseConnection.getConnection();
                PreparedStatement ps;
        String name = this.getName();
        
        try {
            ps = con.prepareStatement("UPDATE characters SET auto"+type+" = "+num+" WHERE name = ?");
                    ps.setString(1, name);
                    ps.executeUpdate();
                    ps.close();

         }       
        
            catch (SQLException e) {cm.dropMessage("Exception has occured: "+e); return;}
        }
        
        public int getAuto(String type) {
                ServernoticeMapleClientMessageCallback cm = new ServernoticeMapleClientMessageCallback(this.getClient());
        Connection con = DatabaseConnection.getConnection();
                PreparedStatement ps;
        String name = this.getName();
        int autoint = 0;
        
        try {
            ps = con.prepareStatement("SELECT * FROM characters WHERE name = ?");
                    ps.setString(1, name);
                    ResultSet rs = ps.executeQuery();
                    if (!rs.next())
                    {
                        ps.close();
                    }
                    autoint = rs.getInt("auto"+type);
                    ps.close();
                    return autoint;
            }      
        
            catch (SQLException e) {cm.dropMessage("Exception has occured: "+e);}
            return autoint;
        }

Now you need to add these two public commands for your players to set what ammount it will auto heal at. This is how i set up my commands:
Code:
if (splitted[0].equals("#sethp"))
                        {
                            if (splitted.length > 1)
                {
                    int hp = Integer.parseInt(splitted[1]);
                                        player.setAuto("hp", hp);
                                        mc.dropMessage("You will be automatically healed if your hp goes below "+hp+"");
                        }
                        }
                        
                        else if (splitted[0].equals("#setmp"))
                        {
                            if (splitted.length > 1)
                {
                    int mp = Integer.parseInt(splitted[1]);
                                        player.setAuto("mp", mp);
                                        mc.dropMessage("You will be automatically healed if your mp goes below "+mp+"");
                        }
                        }

Last, Execute these two query's in that database:
Code:
ALTER TABLE `characters` ADD COLUMN `autohp` INTEGER UNSIGNED NOT NULL DEFAULT 0;
ALTER TABLE `characters` ADD COLUMN `automp` INTEGER UNSIGNED NOT NULL DEFAULT 0;

That should do it and your hp and mp pouches should be working perfectly. I hope you enjoy this.

Edit: Bavilo's alternative script that will take mesos away instead of using the potions and will give 5k hp or mp:
Code:
if (hpp || mpp) {
                    if (hpp) {                        
                        if (player.getHp() < player.getAuto("hp") && player.getMeso() >= 10000) {                              
                                    c.getPlayer().gainMeso(-10000, true, false, true);
                                    mii.getItemEffect(2000005).applyTo(c.getPlayer());
                                
                    }
                    }
                    
                    if (mpp) {
                        if (player.getMp() < player.getAuto("mp") && player.getMeso() >= 10000) {   
                                c.getPlayer().gainMeso(-10000, true, false, true);
                                    mii.getItemEffect(2000005).applyTo(c.getPlayer());
                    }
                    
                }
                
        }
 
Last edited:
Newbie Spellweaver
Joined
May 24, 2008
Messages
8
Reaction score
0
Re: [Release] Hp and Mp Pouches for Pets!

good job. hopefully this works for other repacks & such.
 
Experienced Elementalist
Loyal Member
Joined
Apr 23, 2008
Messages
240
Reaction score
0
Re: [Release] Hp and Mp Pouches for Pets!

I'm gonna try this.

EDIT: It works for me xP. I just have to test it out now.

btw. you have to use

add these imports im not telling you where this is easy enuf
Code:
MapleInventory
MapleItemInformationProvider
ServernoticeMapleClientMessageCallback

put those in your movepethandler
 
Last edited:
IHF
Joined
Apr 7, 2008
Messages
312
Reaction score
0
Re: [Release] Hp and Mp Pouches for Pets!

Will test this out thanks :D
 
Banned
Banned
Joined
Jun 21, 2008
Messages
143
Reaction score
0
Re: [Release] Hp and Mp Pouches for Pets!

Already tested. And it works great as mentioned.

Good work <3
 
Junior Spellweaver
Joined
Jul 19, 2008
Messages
151
Reaction score
0
Re: [Release] Hp and Mp Pouches for Pets!

Thanks! Kudos to you!
 
Newbie Spellweaver
Joined
Mar 19, 2007
Messages
93
Reaction score
12
Re: [Release] Hp and Mp Pouches for Pets!

Yes Bavilo was helping me test it after i coded it. The only mistake i had made during the whole thing was that it added one to your item count instead of taking it away
 
Junior Spellweaver
Joined
Sep 27, 2006
Messages
195
Reaction score
1
Re: [Release] Hp and Mp Pouches for Pets!

init:
deps-jar:
Compiling 3 source files to C:\kelvinchia\build\classes
C:\PhoenixMS\src\net\sf\odinms\client\MapleCharacter.java:2749: cannot find symbol
symbol : class ServernoticeMapleClientMessageCallback
location: class net.sf.odinms.client.MapleCharacter
ServernoticeMapleClientMessageCallback cm = new ServernoticeMapleClientMessageCallback(this.getClient());
C:\PhoenixMS\src\net\sf\odinms\client\MapleCharacter.java:2749: cannot find symbol
symbol : class ServernoticeMapleClientMessageCallback
location: class net.sf.odinms.client.MapleCharacter
ServernoticeMapleClientMessageCallback cm = new ServernoticeMapleClientMessageCallback(this.getClient());
C:\PhoenixMS\src\net\sf\odinms\client\MapleCharacter.java:2766: cannot find symbol
symbol : class ServernoticeMapleClientMessageCallback
location: class net.sf.odinms.client.MapleCharacter
ServernoticeMapleClientMessageCallback cm = new ServernoticeMapleClientMessageCallback(this.getClient());
C:\PhoenixMS\src\net\sf\odinms\client\MapleCharacter.java:2766: cannot find symbol
symbol : class ServernoticeMapleClientMessageCallback
location: class net.sf.odinms.client.MapleCharacter
ServernoticeMapleClientMessageCallback cm = new ServernoticeMapleClientMessageCallback(this.getClient());
C:\PhoenixMS\src\net\sf\odinms\net\channel\handler\MovePetHandler.java:60: cannot find symbol
symbol : class MapleInventory
location: class net.sf.odinms.net.channel.handler.MovePetHandler
MapleInventory use = player.getInventory(MapleInventoryType.USE);
C:\PhoenixMS\src\net\sf\odinms\net\channel\handler\MovePetHandler.java:61: cannot find symbol
symbol : class MapleItemInformationProvider
location: class net.sf.odinms.net.channel.handler.MovePetHandler
MapleItemInformationProvider mii = MapleItemInformationProvider.getInstance();
C:\PhoenixMS\src\net\sf\odinms\net\channel\handler\MovePetHandler.java:61: cannot find symbol
symbol : variable MapleItemInformationProvider
location: class net.sf.odinms.net.channel.handler.MovePetHandler
MapleItemInformationProvider mii = MapleItemInformationProvider.getInstance();
C:\PhoenixMS\src\net\sf\odinms\net\channel\handler\MovePetHandler.java:219: cannot find symbol
symbol : variable MapleItemInformationProvider
location: class net.sf.odinms.net.channel.handler.MovePetHandler
MapleInventoryManipulator.removeById(c, MapleItemInformationProvider.getInstance().getInventoryType(2020013), 2020013, 1, true, false);
C:\PhoenixMS\src\net\sf\odinms\net\channel\handler\MovePetHandler.java:227: cannot find symbol
symbol : variable MapleItemInformationProvider
location: class net.sf.odinms.net.channel.handler.MovePetHandler
MapleInventoryManipulator.removeById(c, MapleItemInformationProvider.getInstance().getInventoryType(2020015), 2020015, 1, true, false);
9 errors
BUILD FAILED (total time: 0 seconds)
 
Newbie Spellweaver
Joined
Jul 22, 2008
Messages
74
Reaction score
0
Re: [Release] Hp and Mp Pouches for Pets!

where do i put those public commands? for the players?
 
Legendary Battlemage
Joined
May 23, 2008
Messages
628
Reaction score
4
Re: [Release] Hp and Mp Pouches for Pets!

Anywhere? lol?
Testing.
 
Newbie Spellweaver
Joined
Mar 19, 2007
Messages
93
Reaction score
12
Re: [Release] Hp and Mp Pouches for Pets!

in your commandproccessor.java. You will have to define info for public commands first though.
 
Newbie Spellweaver
Joined
Mar 19, 2007
Messages
93
Reaction score
12
Re: [Release] Hp and Mp Pouches for Pets!

XkelvinchiaX, your stuff had some spcaes in it from when you copied and pasted, i think thats all i saw
 
Junior Spellweaver
Joined
Aug 9, 2008
Messages
111
Reaction score
0
Re: [Release] Hp and Mp Pouches for Pets!

init:
deps-jar:
Compiling 3 source files to C:\kelvinchia\build\classes
C:\PhoenixMS\src\net\sf\odinms\client\MapleCharacter.java:2749: cannot find symbol
symbol : class ServernoticeMapleClientMessageCallback
location: class net.sf.odinms.client.MapleCharacter
ServernoticeMapleClientMessageCallback cm = new ServernoticeMapleClientMessageCallback(this.getClient());
C:\PhoenixMS\src\net\sf\odinms\client\MapleCharacter.java:2749: cannot find symbol
symbol : class ServernoticeMapleClientMessageCallback
location: class net.sf.odinms.client.MapleCharacter
ServernoticeMapleClientMessageCallback cm = new ServernoticeMapleClientMessageCallback(this.getClient());
C:\PhoenixMS\src\net\sf\odinms\client\MapleCharacter.java:2766: cannot find symbol
symbol : class ServernoticeMapleClientMessageCallback
location: class net.sf.odinms.client.MapleCharacter
ServernoticeMapleClientMessageCallback cm = new ServernoticeMapleClientMessageCallback(this.getClient());
C:\PhoenixMS\src\net\sf\odinms\client\MapleCharacter.java:2766: cannot find symbol
symbol : class ServernoticeMapleClientMessageCallback
location: class net.sf.odinms.client.MapleCharacter
ServernoticeMapleClientMessageCallback cm = new ServernoticeMapleClientMessageCallback(this.getClient());
C:\PhoenixMS\src\net\sf\odinms\net\channel\handler\MovePetHandler.java:60: cannot find symbol
symbol : class MapleInventory
location: class net.sf.odinms.net.channel.handler.MovePetHandler
MapleInventory use = player.getInventory(MapleInventoryType.USE);
C:\PhoenixMS\src\net\sf\odinms\net\channel\handler\MovePetHandler.java:61: cannot find symbol
symbol : class MapleItemInformationProvider
location: class net.sf.odinms.net.channel.handler.MovePetHandler
MapleItemInformationProvider mii = MapleItemInformationProvider.getInstance();
C:\PhoenixMS\src\net\sf\odinms\net\channel\handler\MovePetHandler.java:61: cannot find symbol
symbol : variable MapleItemInformationProvider
location: class net.sf.odinms.net.channel.handler.MovePetHandler
MapleItemInformationProvider mii = MapleItemInformationProvider.getInstance();
C:\PhoenixMS\src\net\sf\odinms\net\channel\handler\MovePetHandler.java:219: cannot find symbol
symbol : variable MapleItemInformationProvider
location: class net.sf.odinms.net.channel.handler.MovePetHandler
MapleInventoryManipulator.removeById(c, MapleItemInformationProvider.getInstance().getInventoryType(2020013), 2020013, 1, true, false);
C:\PhoenixMS\src\net\sf\odinms\net\channel\handler\MovePetHandler.java:227: cannot find symbol
symbol : variable MapleItemInformationProvider
location: class net.sf.odinms.net.channel.handler.MovePetHandler
MapleInventoryManipulator.removeById(c, MapleItemInformationProvider.getInstance().getInventoryType(2020015), 2020015, 1, true, false);
9 errors
BUILD FAILED (total time: 0 seconds)


same here
 
Junior Spellweaver
Joined
Sep 27, 2006
Messages
195
Reaction score
1
Re: [Release] Hp and Mp Pouches for Pets!

how about this??

Code:
init:
deps-jar:
Compiling 3 source files to C:\kelvinchia\build\classes
C:\PhoenixMS\src\net\sf\odinms\client\MapleCharacter.java:2749: cannot find symbol
symbol  : class ServernoticeMapleClientMessageCallback
location: class net.sf.odinms.client.MapleCharacter
                ServernoticeMapleClientMessageCallback cm = new ServernoticeMapleClientMessageCallback(this.getClient());
C:\PhoenixMS\src\net\sf\odinms\client\MapleCharacter.java:2749: cannot find symbol
symbol  : class ServernoticeMapleClientMessageCallback
location: class net.sf.odinms.client.MapleCharacter
                ServernoticeMapleClientMessageCallback cm = new ServernoticeMapleClientMessageCallback(this.getClient());
C:\PhoenixMS\src\net\sf\odinms\client\MapleCharacter.java:2766: cannot find symbol
symbol  : class ServernoticeMapleClientMessageCallback
location: class net.sf.odinms.client.MapleCharacter
                ServernoticeMapleClientMessageCallback cm = new ServernoticeMapleClientMessageCallback(this.getClient());
C:\PhoenixMS\src\net\sf\odinms\client\MapleCharacter.java:2766: cannot find symbol
symbol  : class ServernoticeMapleClientMessageCallback
location: class net.sf.odinms.client.MapleCharacter
                ServernoticeMapleClientMessageCallback cm = new ServernoticeMapleClientMessageCallback(this.getClient());
C:\PhoenixMS\src\net\sf\odinms\net\channel\handler\MovePetHandler.java:60: cannot find symbol
symbol  : class MapleInventory
location: class net.sf.odinms.net.channel.handler.MovePetHandler
                MapleInventory use = player.getInventory(MapleInventoryType.USE);
C:\PhoenixMS\src\net\sf\odinms\net\channel\handler\MovePetHandler.java:61: cannot find symbol
symbol  : class MapleItemInformationProvider
location: class net.sf.odinms.net.channel.handler.MovePetHandler
                MapleItemInformationProvider mii = MapleItemInformationProvider.getInstance();
C:\PhoenixMS\src\net\sf\odinms\net\channel\handler\MovePetHandler.java:61: cannot find symbol
symbol  : variable MapleItemInformationProvider
location: class net.sf.odinms.net.channel.handler.MovePetHandler
                MapleItemInformationProvider mii = MapleItemInformationProvider.getInstance();
C:\PhoenixMS\src\net\sf\odinms\net\channel\handler\MovePetHandler.java:219: cannot find symbol
symbol  : variable MapleItemInformationProvider
location: class net.sf.odinms.net.channel.handler.MovePetHandler
                                    MapleInventoryManipulator.removeById(c, MapleItemInformationProvider.getInstance().getInventoryType(2020013), 2020013, 1, true, false);
C:\PhoenixMS\src\net\sf\odinms\net\channel\handler\MovePetHandler.java:226: cannot find symbol
symbol  : variable MapleItemInformationProvider
location: class net.sf.odinms.net.channel.handler.MovePetHandler
                                    MapleInventoryManipulator.removeById(c, MapleItemInformationProvider.getInstance().getInventoryType(2020015), 2020015, 1, true, false);
9 errors
BUILD FAILED (total time: 0 seconds)
 
Newbie Spellweaver
Joined
Mar 19, 2007
Messages
93
Reaction score
12
Re: [Release] Hp and Mp Pouches for Pets!

Um here is my entire public command section:
Code:
if (line.charAt(0) == '#')    //commands anyone can use
        {
            String[] splitted = line.split(" ");
            
            if (splitted[0].equals("#henesys") && player.getMapId() != 200090300 && player.getMapId() != 980000404)
            {
                MapleMap target = cserv.getMapFactory().getMap(100000000);
                MaplePortal targetPortal = target.getPortal(0);
                player.changeMap(target, targetPortal);
            }
            
            else if (splitted[0].equals("#kerning") && player.getMapId() != 200090300 && player.getMapId() != 980000404)
            {
                MapleMap target = cserv.getMapFactory().getMap(103000000);
                MaplePortal targetPortal = target.getPortal(0);
                player.changeMap(target, targetPortal);
            }
            
            else if (splitted[0].equals("#perion") && player.getMapId() != 200090300 && player.getMapId() != 980000404)
            {
                MapleMap target = cserv.getMapFactory().getMap(102000000);
                MaplePortal targetPortal = target.getPortal(0);
                player.changeMap(target, targetPortal);
            }
            
            else if (splitted[0].equals("#ellinia") && player.getMapId() != 200090300 && player.getMapId() != 980000404)
            {
                MapleMap target = cserv.getMapFactory().getMap(101000000);
                MaplePortal targetPortal = target.getPortal(0);
                player.changeMap(target, targetPortal);
            }
                        
                        else if (splitted[0].equals("#sethp"))
                        {
                            if (splitted.length > 1)
                {
                    int hp = Integer.parseInt(splitted[1]);
                                        player.setAuto("hp", hp);
                                        mc.dropMessage("You will be automatically healed if your hp goes below "+hp+"");
                        }
                        }
                        
                        else if (splitted[0].equals("#setmp"))
                        {
                            if (splitted.length > 1)
                {
                    int mp = Integer.parseInt(splitted[1]);
                                        player.setAuto("mp", mp);
                                        mc.dropMessage("You will be automatically healed if your mp goes below "+mp+"");
                        }
                        }
                        
                        else
            {
                mc.dropMessage("Invalid command.");
            }
            
            return true;
        }
 
Experienced Elementalist
Joined
Jun 25, 2008
Messages
260
Reaction score
0
Re: [Release] Hp and Mp Pouches for Pets!

Um here is my entire public command section:
Code:
if (line.charAt(0) == '#')    //commands anyone can use
        {
            String[] splitted = line.split(" ");
            
            if (splitted[0].equals("#henesys") && player.getMapId() != 200090300 && player.getMapId() != 980000404)
            {
                MapleMap target = cserv.getMapFactory().getMap(100000000);
                MaplePortal targetPortal = target.getPortal(0);
                player.changeMap(target, targetPortal);
            }
            
            else if (splitted[0].equals("#kerning") && player.getMapId() != 200090300 && player.getMapId() != 980000404)
            {
                MapleMap target = cserv.getMapFactory().getMap(103000000);
                MaplePortal targetPortal = target.getPortal(0);
                player.changeMap(target, targetPortal);
            }
            
            else if (splitted[0].equals("#perion") && player.getMapId() != 200090300 && player.getMapId() != 980000404)
            {
                MapleMap target = cserv.getMapFactory().getMap(102000000);
                MaplePortal targetPortal = target.getPortal(0);
                player.changeMap(target, targetPortal);
            }
            
            else if (splitted[0].equals("#ellinia") && player.getMapId() != 200090300 && player.getMapId() != 980000404)
            {
                MapleMap target = cserv.getMapFactory().getMap(101000000);
                MaplePortal targetPortal = target.getPortal(0);
                player.changeMap(target, targetPortal);
            }
                        
                        else if (splitted[0].equals("#sethp"))
                        {
                            if (splitted.length > 1)
                {
                    int hp = Integer.parseInt(splitted[1]);
                                        player.setAuto("hp", hp);
                                        mc.dropMessage("You will be automatically healed if your hp goes below "+hp+"");
                        }
                        }
                        
                        else if (splitted[0].equals("#setmp"))
                        {
                            if (splitted.length > 1)
                {
                    int mp = Integer.parseInt(splitted[1]);
                                        player.setAuto("mp", mp);
                                        mc.dropMessage("You will be automatically healed if your mp goes below "+mp+"");
                        }
                        }
                        
                        else
            {
                mc.dropMessage("Invalid command.");
            }
            
            return true;
        }

can you change the "#" to any sign you want for ex this "!"?
 
Newbie Spellweaver
Joined
Mar 19, 2007
Messages
93
Reaction score
12
Re: [Release] Hp and Mp Pouches for Pets!

yeah, the # was just my choice, but you can use anything,!@#$%^&*()...etc.
 
Newbie Spellweaver
Joined
Jul 22, 2008
Messages
74
Reaction score
0
Re: [Release] Hp and Mp Pouches for Pets!

wait, so we add what you quoted above in our commandprocessor.java at the bottom? Because i cant seem to find a publiccommand file
 
Back
Top