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!

[HELP] NPCScript Remove Item from Inventoryitems2

Joined
Apr 25, 2010
Messages
479
Reaction score
49
NPCConversation

PHP:
  public void getRemoveItems() {
        Connection con = DatabaseConnection.getConnection();
        try {
            PreparedStatement ps = con.prepareStatement("SELECT * FROM inventoryitems2 " + "LEFT JOIN inventoryequipment USING (inventoryitemid) " + "WHERE characterid = ?");
            ps.setInt(1, getPlayer().getId());
            ResultSet rs = ps.executeQuery();
            while (rs.next()) {
                    MapleInventoryType type = MapleInventoryType.getByType((byte) rs.getInt("inventorytype"));
                    if (type.equals(MapleInventoryType.EQUIP) || type.equals(MapleInventoryType.EQUIPPED)) {
                        int itemid = rs.getInt("itemid");
                        Equip equip = new Equip(itemid, (byte) rs.getInt("position"), rs.getInt("ringid"));
                        equip.setOwner(rs.getString("owner"));
                        equip.setQuantity((short) rs.getInt("quantity"));
                        equip.setAcc((short) rs.getInt("acc"));
                        equip.setAvoid((short) rs.getInt("avoid"));
                        equip.setDex((short) rs.getInt("dex"));
                        equip.setHands((short) rs.getInt("hands"));
                        equip.setHp((short) rs.getInt("hp"));
                        equip.setInt((short) rs.getInt("int"));
                        equip.setJump((short) rs.getInt("jump"));
                        equip.setLuk((short) rs.getInt("luk"));
                        equip.setMatk((short) rs.getInt("matk"));
                        equip.setMdef((short) rs.getInt("mdef"));
                        equip.setMp((short) rs.getInt("mp"));
                        equip.setSpeed((short) rs.getInt("speed"));
                        equip.setStr((short) rs.getInt("str"));
                        equip.setWatk((short) rs.getInt("watk"));
                        equip.setWdef((short) rs.getInt("wdef"));
                        equip.setUpgradeSlots((byte) rs.getInt("upgradeslots"));
                        equip.setLocked((byte) rs.getInt("locked"));
                        equip.setLevel((byte) rs.getInt("level"));
                        ret.items.add(equip);
                    } 
                }
                rs.close();
                ps.close();
            }
        } catch (SQLException ex) {
            log.error("Error loading inventoryitems2", ex);
        }
        return ret;
    }

NPCScript

PHP:
function start() {
	status = -1;
	action(1, 0, 0);
}

function action() {
cm.getRemoveItems();
cm.dispose();
}

I need to remove items from a table of items, wanted to know if this coding right?
If not you help me fix it?
 
Experienced Elementalist
Joined
Apr 8, 2008
Messages
203
Reaction score
29
If you want to remove items from a table, you will need to use a DELETE query.
The routine you posted only reads the table for items that exist in both inventoryitems2 and inventoryequipment on charid.
Also it returns a value, although the routine is defined as void.
I cannot see where ret is defined.
 
Upvote 0
Joined
Apr 25, 2010
Messages
479
Reaction score
49
If you want to remove items from a table, you will need to use a DELETE query.
The routine you posted only reads the table for items that exist in both inventoryitems2 and inventoryequipment on charid.
Also it returns a value, although the routine is defined as void.
I cannot see where ret is defined.

So how do I get the table item inventoryitems2 for my equipment?
 
Upvote 0
Experienced Elementalist
Joined
Apr 8, 2008
Messages
203
Reaction score
29
When you say you want to remove the items, do you mean delete them from the table so they no longer exist, or read them from the table so you can equip them?
 
Upvote 0
Joined
Apr 25, 2010
Messages
479
Reaction score
49
I want to remove them from the table (iventoryitems2) and sends them to my equipment.
Example: Like when you open a Merchant and your items are in fredrick.
 
Upvote 0
Joined
Jan 11, 2013
Messages
589
Reaction score
82
Oh, funny i think i have the similiar idea as you. I played VindiMs and they have a ap-storage bank, is that what your trying to create? I'm trying to make a NPC on my server that holds ap stats/skills pt/etc. However, i have no where to being lmao. Hope u succeed this wil be very interesting.
 
Upvote 0
Custom Title Activated
Member
Joined
Apr 29, 2008
Messages
1,297
Reaction score
509
Oh, funny i think i have the similiar idea as you. I played VindiMs and they have a ap-storage bank, is that what your trying to create? I'm trying to make a NPC on my server that holds ap stats/skills pt/etc. However, i have no where to being lmao. Hope u succeed this wil be very interesting.

Isn't that easy to do?

Anyway, OT : Can you even compile your file? It's a void function but it's returning "ret" which I have no idea where that's from.
 
Upvote 0
Back
Top