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!

[Mini add-on]Fixing MoopleDev rev 107's cm.haveItem

Newbie Spellweaver
Loyal Member
Joined
Mar 25, 2008
Messages
71
Reaction score
19
It's fairly simple. For those who don't have it "broken", that's kinda weird. I SVN updated..two days ago, and the cm.haveItem was broken. Anyways, here's the fix.

MapleCharacter.java
find
PHP:
    public boolean haveItem(int itemid) {
        return getItemQuantity(itemid, false) > 0;
    }
add under
PHP:
    public boolean haveItem(int itemid, int quantity, boolean checkEquipped, boolean greaterOrEquals) {
        int possesed = inventory[MapleItemInformationProvider.getInstance().getInventoryType(itemid).ordinal()].countById(itemid);
        if (checkEquipped) {
            possesed += inventory[MapleInventoryType.EQUIPPED.ordinal()].countById(itemid);
        }
        return greaterOrEquals ? possesed >= quantity : possesed == quantity;
    }

AbstractPlayerInteraction.java
find
PHP:
    public boolean haveItem(int itemid) {
        return haveItem(itemid, 1);
    }

    public boolean haveItem(int itemid, int quantity) {
        return getPlayer().getItemQuantity(itemid, false) >= quantity;
    }
replace with
PHP:
    public boolean haveItem(int itemid) {
        return haveItem(itemid, 1);
    }

    public boolean haveItem(int itemid, int quantity) {
        return haveItem(itemid, quantity, false, true);
    }

    public boolean haveItem(int itemid, int quantity, boolean checkEquipped, boolean greaterOrEquals) {
        return c.getPlayer().haveItem(itemid, quantity, checkEquipped, greaterOrEquals);
    }
Compile, and now cm.haveItem(itemid, amount) will work. I know it's not much, but I found it very useful.
 
Legendary Battlemage
Loyal Member
Joined
Dec 13, 2010
Messages
649
Reaction score
140
Hmm. I wouldn't say its a fix, more of an addition. Since there was nothing WRONG with what they had, it just wasn't as good as being able to check the amount, which people could technically get from any modern source...
 
Back
Top