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:
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:
Re: [Release] Hp and Mp Pouches for Pets!

Already tested. And it works great as mentioned.

Good work <3
 
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
 
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)
 
Re: [Release] Hp and Mp Pouches for Pets!

in your commandproccessor.java. You will have to define info for public commands first though.
 
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
 
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)
 
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;
        }
 
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 "!"?
 
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