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!

Dropping Items

Newbie Spellweaver
Joined
Oct 3, 2017
Messages
13
Reaction score
1
Hello ragezone.

I am trying to use LeaderMS source and I found out that if I try to drop a item with a quantity of more then 1 then it will just drop one instead of showing me the window of 'How many would you like to drop'.

Example:


I was thinking that it has to do with my ItemMoveHandler but I am not sure.
Code:
[COLOR=#CC7832]package [/COLOR][COLOR=#A9B7C6]handling.channel.handler[/COLOR][COLOR=#CC7832];[/COLOR][COLOR=#cc7832]
[/COLOR][COLOR=#cc7832]import [/COLOR]client.MapleClient[COLOR=#cc7832];
[/COLOR][COLOR=#cc7832]import [/COLOR]client.inventory.MapleInventoryType[COLOR=#cc7832];
[/COLOR][COLOR=#cc7832]import [/COLOR]handling.AbstractMaplePacketHandler[COLOR=#cc7832];
[/COLOR][COLOR=#cc7832]import [/COLOR]server.AutobanManager[COLOR=#cc7832];
[/COLOR][COLOR=#cc7832]import [/COLOR]server.MapleInventoryManipulator[COLOR=#cc7832];
[/COLOR][COLOR=#cc7832]import [/COLOR]tools.data.input.SeekableLittleEndianAccessor[COLOR=#cc7832];
[/COLOR][COLOR=#cc7832]
[/COLOR][COLOR=#cc7832]public class [/COLOR]ItemMoveHandler [COLOR=#cc7832]extends [/COLOR]AbstractMaplePacketHandler {

    [COLOR=#629755][I]/**
[/I][/COLOR][COLOR=#629755][I]     * Creates a new instance of ItemMoveHandler
[/I][/COLOR][COLOR=#629755][I]     */
[/I][/COLOR][COLOR=#629755][I]    [/I][/COLOR][COLOR=#cc7832]public [/COLOR][COLOR=#ffc66d]ItemMoveHandler[/COLOR]() {
    }

    [COLOR=#cc7832]public void [/COLOR][COLOR=#ffc66d]handlePacket[/COLOR](SeekableLittleEndianAccessor slea[COLOR=#cc7832], [/COLOR]MapleClient c) {
        slea.readInt()[COLOR=#cc7832];
[/COLOR][COLOR=#cc7832]        [/COLOR]MapleInventoryType type = MapleInventoryType.[I]getByType[/I](slea.readByte())[COLOR=#cc7832];
[/COLOR][COLOR=#cc7832]        byte [/COLOR]src = ([COLOR=#cc7832]byte[/COLOR]) slea.readShort()[COLOR=#cc7832];
[/COLOR][COLOR=#cc7832]        byte [/COLOR]dst = ([COLOR=#cc7832]byte[/COLOR]) slea.readShort()[COLOR=#cc7832];
[/COLOR][COLOR=#cc7832]        long [/COLOR]checkq = slea.readShort()[COLOR=#cc7832];
[/COLOR][COLOR=#cc7832]        short [/COLOR]quantity = ([COLOR=#cc7832]short[/COLOR])([COLOR=#cc7832]int[/COLOR])checkq[COLOR=#cc7832];
[/COLOR][COLOR=#cc7832]        if [/COLOR](src < [COLOR=#6897bb]0 [/COLOR]&& dst > [COLOR=#6897bb]0[/COLOR]) {
            MapleInventoryManipulator.[I]unequip[/I](c[COLOR=#cc7832], [/COLOR]src[COLOR=#cc7832], [/COLOR]dst)[COLOR=#cc7832];
[/COLOR][COLOR=#cc7832]        [/COLOR]} [COLOR=#cc7832]else if [/COLOR](dst < [COLOR=#6897bb]0[/COLOR]) {
            MapleInventoryManipulator.[I]equip[/I](c[COLOR=#cc7832], [/COLOR]src[COLOR=#cc7832], [/COLOR]dst)[COLOR=#cc7832];
[/COLOR][COLOR=#cc7832]        [/COLOR]} [COLOR=#cc7832]else if [/COLOR](dst == [COLOR=#6897bb]0[/COLOR]) {
            [COLOR=#cc7832]if [/COLOR](c.getPlayer().getInventory(type).getItem(src) == [COLOR=#cc7832]null[/COLOR]) [COLOR=#cc7832]return;
[/COLOR][COLOR=#cc7832]            if [/COLOR](checkq > [COLOR=#6897bb]4000 [/COLOR]|| checkq < [COLOR=#6897bb]1[/COLOR]) {
                AutobanManager.[I]getInstance[/I]().autoban(c[COLOR=#cc7832], [/COLOR][COLOR=#6a8759]"Drop-dupe ("[/COLOR]+c.getPlayer().getInventory(type).getItem(src).getItemId()+[COLOR=#6a8759]")."[/COLOR])[COLOR=#cc7832];
[/COLOR][COLOR=#cc7832]                return;
[/COLOR][COLOR=#cc7832]            [/COLOR]}
            MapleInventoryManipulator.[I]drop[/I](c[COLOR=#cc7832], [/COLOR]type[COLOR=#cc7832], [/COLOR]src[COLOR=#cc7832], [/COLOR]quantity)[COLOR=#cc7832];
[/COLOR][COLOR=#cc7832]        [/COLOR]} [COLOR=#cc7832]else [/COLOR]{
            MapleInventoryManipulator.[I]move[/I](c[COLOR=#cc7832], [/COLOR]type[COLOR=#cc7832], [/COLOR]src[COLOR=#cc7832], [/COLOR]dst)[COLOR=#cc7832];
[/COLOR][COLOR=#cc7832]        [/COLOR]}
    }
[COLOR=#A9B7C6]}[/COLOR]

Please help.
 
Junior Spellweaver
Joined
Sep 16, 2017
Messages
156
Reaction score
36
Mmm,
PHP:
long checkq = slea.readShort();
short quantity = (short)(int)checkq;
I'm not sure about this part. A readShort(), as the name suggests, would return a short, but it's stored in a long, that's then double-casted to int and short.

Unless I'm missing something, you might wanna remove that checkq variable, and simply use quantity instead, in all the places where checkq was used:

PHP:
short quantity = slea.readShort();
// ...
if (quantity > 4000 || quantity < 1) {

As a side note, be careful with this very last if. It's fine as long as you won't have any item that's allowed to stack over 4000 units; but, in case you'll allow for certain droppable items to stack more, you'll have to modify that statement, otherwise people would get automatically banned whenever trying to drop more than 4000 items at the same time.
 
Upvote 0
Joined
Apr 25, 2010
Messages
479
Reaction score
49
Hello ragezone.

I am trying to use LeaderMS source and I found out that if I try to drop a item with a quantity of more then 1 then it will just drop one instead of showing me the window of 'How many would you like to drop'.

Example:


I was thinking that it has to do with my ItemMoveHandler but I am not sure.
Code:
[COLOR=#CC7832]package [/COLOR][COLOR=#A9B7C6]handling.channel.handler[/COLOR][COLOR=#CC7832];[/COLOR][COLOR=#cc7832]
[/COLOR][COLOR=#cc7832]import [/COLOR]client.MapleClient[COLOR=#cc7832];
[/COLOR][COLOR=#cc7832]import [/COLOR]client.inventory.MapleInventoryType[COLOR=#cc7832];
[/COLOR][COLOR=#cc7832]import [/COLOR]handling.AbstractMaplePacketHandler[COLOR=#cc7832];
[/COLOR][COLOR=#cc7832]import [/COLOR]server.AutobanManager[COLOR=#cc7832];
[/COLOR][COLOR=#cc7832]import [/COLOR]server.MapleInventoryManipulator[COLOR=#cc7832];
[/COLOR][COLOR=#cc7832]import [/COLOR]tools.data.input.SeekableLittleEndianAccessor[COLOR=#cc7832];
[/COLOR][COLOR=#cc7832]
[/COLOR][COLOR=#cc7832]public class [/COLOR]ItemMoveHandler [COLOR=#cc7832]extends [/COLOR]AbstractMaplePacketHandler {

    [COLOR=#629755][I]/**
[/I][/COLOR][COLOR=#629755][I]     * Creates a new instance of ItemMoveHandler
[/I][/COLOR][COLOR=#629755][I]     */
[/I][/COLOR][COLOR=#629755][I]    [/I][/COLOR][COLOR=#cc7832]public [/COLOR][COLOR=#ffc66d]ItemMoveHandler[/COLOR]() {
    }

    [COLOR=#cc7832]public void [/COLOR][COLOR=#ffc66d]handlePacket[/COLOR](SeekableLittleEndianAccessor slea[COLOR=#cc7832], [/COLOR]MapleClient c) {
        slea.readInt()[COLOR=#cc7832];
[/COLOR][COLOR=#cc7832]        [/COLOR]MapleInventoryType type = MapleInventoryType.[I]getByType[/I](slea.readByte())[COLOR=#cc7832];
[/COLOR][COLOR=#cc7832]        byte [/COLOR]src = ([COLOR=#cc7832]byte[/COLOR]) slea.readShort()[COLOR=#cc7832];
[/COLOR][COLOR=#cc7832]        byte [/COLOR]dst = ([COLOR=#cc7832]byte[/COLOR]) slea.readShort()[COLOR=#cc7832];
[/COLOR][COLOR=#cc7832]        long [/COLOR]checkq = slea.readShort()[COLOR=#cc7832];
[/COLOR][COLOR=#cc7832]        short [/COLOR]quantity = ([COLOR=#cc7832]short[/COLOR])([COLOR=#cc7832]int[/COLOR])checkq[COLOR=#cc7832];
[/COLOR][COLOR=#cc7832]        if [/COLOR](src < [COLOR=#6897bb]0 [/COLOR]&& dst > [COLOR=#6897bb]0[/COLOR]) {
            MapleInventoryManipulator.[I]unequip[/I](c[COLOR=#cc7832], [/COLOR]src[COLOR=#cc7832], [/COLOR]dst)[COLOR=#cc7832];
[/COLOR][COLOR=#cc7832]        [/COLOR]} [COLOR=#cc7832]else if [/COLOR](dst < [COLOR=#6897bb]0[/COLOR]) {
            MapleInventoryManipulator.[I]equip[/I](c[COLOR=#cc7832], [/COLOR]src[COLOR=#cc7832], [/COLOR]dst)[COLOR=#cc7832];
[/COLOR][COLOR=#cc7832]        [/COLOR]} [COLOR=#cc7832]else if [/COLOR](dst == [COLOR=#6897bb]0[/COLOR]) {
            [COLOR=#cc7832]if [/COLOR](c.getPlayer().getInventory(type).getItem(src) == [COLOR=#cc7832]null[/COLOR]) [COLOR=#cc7832]return;
[/COLOR][COLOR=#cc7832]            if [/COLOR](checkq > [COLOR=#6897bb]4000 [/COLOR]|| checkq < [COLOR=#6897bb]1[/COLOR]) {
                AutobanManager.[I]getInstance[/I]().autoban(c[COLOR=#cc7832], [/COLOR][COLOR=#6a8759]"Drop-dupe ("[/COLOR]+c.getPlayer().getInventory(type).getItem(src).getItemId()+[COLOR=#6a8759]")."[/COLOR])[COLOR=#cc7832];
[/COLOR][COLOR=#cc7832]                return;
[/COLOR][COLOR=#cc7832]            [/COLOR]}
            MapleInventoryManipulator.[I]drop[/I](c[COLOR=#cc7832], [/COLOR]type[COLOR=#cc7832], [/COLOR]src[COLOR=#cc7832], [/COLOR]quantity)[COLOR=#cc7832];
[/COLOR][COLOR=#cc7832]        [/COLOR]} [COLOR=#cc7832]else [/COLOR]{
            MapleInventoryManipulator.[I]move[/I](c[COLOR=#cc7832], [/COLOR]type[COLOR=#cc7832], [/COLOR]src[COLOR=#cc7832], [/COLOR]dst)[COLOR=#cc7832];
[/COLOR][COLOR=#cc7832]        [/COLOR]}
    }
[COLOR=#A9B7C6]}[/COLOR]

Please help.

I corrected this to times ago, you're looking at the wrong place. Probably the error is in additeminfo in maplepacketcreator, check there.
 
Upvote 0
Newbie Spellweaver
Joined
Oct 3, 2017
Messages
13
Reaction score
1
@GabrielSin
Ok. I fixed it. It was indeed in addItemInfo. What happened is that I added expiration dates to all items and maplestory doesn't like expirations with dropping items for some reason.

I changed this line.
addExpirationTime(mplew, item.getExpiration(), false);

To:
if(item.getExpiration() > 0) { addExpirationTime(mplew, item.getExpiration(), true);
} else {
addExpirationTime(mplew, item.getExpiration(), false);
}
 
Upvote 0
Back
Top