- Joined
- Nov 30, 2007
- Messages
- 511
- Reaction score
- 0
Using Leifde's pet patch requires that you modify certain things, the gainItem() function included, when pets are involved. If you don't use this fix, your client will crash if you ever use the gainItem() function for pets due to the whole database shabang not being applied to that pet. Here we go:
In AbstractPlayerInteraction.java, replace the gainItem() function with this:
That's about it. You'll need a bunch of imports, but if you're using Netbeans and haven't noticed by now that it gives you the option of adding in all missing imports then you should shoot yourself, sorry.
In AbstractPlayerInteraction.java, replace the gainItem() function with this:
PHP:
public void gainItem(int id, short quantity) {
MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
if (id >= 5000000 && id <= 5000045) {
try {
Connection con = (Connection) DatabaseConnection.getConnection();
PreparedStatement ps = (PreparedStatement) con.prepareStatement("INSERT INTO pets (name, level, closeness, fullness) VALUES (?, ?, ?, ?)");
ps.setString(1, ii.getName(id));
ps.setInt(2, 1);
ps.setInt(3, 0);
ps.setInt(4, 100);
ps.executeUpdate();
ResultSet rs = ps.getGeneratedKeys();
rs.next();
//c.getPlayer().equipChanged();
MapleInventoryManipulator.addById(c, id, (short) quantity, c.getPlayer().getName() + " receieved pet, ID " + id + ", from a scripted PlayerInteraction. (Quantity: " + quantity + ")", null, rs.getInt(1));
rs.close();
ps.close();
} catch (SQLException ex) {
java.util.logging.Logger.getLogger(AbstractPlayerInteraction.class.getName()).log(Level.SEVERE, null, ex);
}
} else {
if (quantity >= 0) {
StringBuilder logInfo = new StringBuilder(c.getPlayer().getName());
logInfo.append(" received ");
logInfo.append(quantity);
logInfo.append(" from a scripted PlayerInteraction (");
logInfo.append(this.toString());
logInfo.append(")");
MapleInventoryManipulator.addById(c, id, quantity, logInfo.toString());
} else {
MapleInventoryManipulator.removeById(c, MapleItemInformationProvider.getInstance().getInventoryType(id), id, -quantity, true, false);
}
}
c.getSession().write(MaplePacketCreator.getShowItemGain(id, quantity, true));
}
That's about it. You'll need a bunch of imports, but if you're using Netbeans and haven't noticed by now that it gives you the option of adding in all missing imports then you should shoot yourself, sorry.
Last edited: