- 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:
Add this after it:
Next Find:
Add this after it:
Above the last two brackets at the bottom of the page, add:
In MapleCharacter.java
Add this at the end of the page inside the last bracket:
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:
Last, Execute these two query's in that database:
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:
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: