Выдача итема у менеджера витамин

Gigi

Выдающийся
Местный
Сообщения
241
Розыгрыши
0
Репутация
173
Реакции
59
Баллы
1 373
Хроники
  1. Prologue: Prelude of War
Исходники
Присутствуют
Сборка
MasterClass ch3
В таблицу character_premium_items сделал новую запись итема. Иконка что предмет есть, в игре появилась, но при выдаче предмета с витаминки пишет такое:

111.jpg
Все методы в итоге ведут сюда - RequestWithDrawPremiumItem.java
Java:
package org.l2jmobius.gameserver.network.clientpackets;

import org.l2jmobius.Config;
import org.l2jmobius.commons.network.ReadablePacket;
import org.l2jmobius.gameserver.model.PremiumItem;
import org.l2jmobius.gameserver.model.actor.Player;
import org.l2jmobius.gameserver.network.GameClient;
import org.l2jmobius.gameserver.network.SystemMessageId;
import org.l2jmobius.gameserver.network.serverpackets.ExGetPremiumItemList;
import org.l2jmobius.gameserver.util.Util;

/**
 * @author Gnacik
 */
public class RequestWithDrawPremiumItem implements ClientPacket
{
    private int _itemNum;
    private int _charId;
    private long _itemCount;
    
    @Override
    public void read(ReadablePacket packet)
    {
        _itemNum = packet.readInt();
        _charId = packet.readInt();
        _itemCount = packet.readLong();
    }
    
    @Override
    public void run(GameClient client)
    {
        final Player player = client.getPlayer();
        if (player == null)
        {
            return;
        }
        else if (_itemCount <= 0)
        {
            return;
        }
        else if (player.getObjectId() != _charId)
        {
            Util.handleIllegalPlayerAction(player, "[RequestWithDrawPremiumItem] Incorrect owner, Player: " + player.getName(), Config.DEFAULT_PUNISH);
            return;
        }
        else if (player.getPremiumItemList().isEmpty())
        {
            Util.handleIllegalPlayerAction(player, "[RequestWithDrawPremiumItem] Player: " + player.getName() + " try to get item with empty list!", Config.DEFAULT_PUNISH);
            return;
        }
        else if ((player.getWeightPenalty() >= 3) || !player.isInventoryUnder90(false))
        {
            player.sendPacket(SystemMessageId.YOU_CANNOT_RECEIVE_THE_DIMENSIONAL_ITEM_BECAUSE_YOU_HAVE_EXCEED_YOUR_INVENTORY_WEIGHT_QUANTITY_LIMIT);
            return;
        }
        else if (player.isProcessingTransaction())
        {
            player.sendPacket(SystemMessageId.ITEMS_FROM_GAME_ASSISTANTS_CANNOT_BE_EXCHANGED);
            return;
        }
        
        final PremiumItem item = player.getPremiumItemList().get(_itemNum);
        if (item == null)
        {
            return;
        }
        else if (item.getCount() < _itemCount)
        {
            return;
        }
        
        final long itemsLeft = (item.getCount() - _itemCount);
        player.addItem("PremiumItem", item.getItemId(), _itemCount, player.getTarget(), true);
        if (itemsLeft > 0)
        {
            item.updateCount(itemsLeft);
            player.updatePremiumItem(_itemNum, itemsLeft);
        }
        else
        {
            player.getPremiumItemList().remove(_itemNum);
            player.deletePremiumItem(_itemNum);
        }
        
        if (player.getPremiumItemList().isEmpty())
        {
            player.sendPacket(SystemMessageId.THERE_ARE_NO_MORE_DIMENSIONAL_ITEMS_TO_BE_FOUND);
        }
        else
        {
            player.sendPacket(new ExGetPremiumItemList(player));
        }
    }
}

Все провеки где Config.DEFAULT_PUNISH - что выдеёт этот месидж верные, и остальные проверки тоже, кароче не смог найти проверку которая запрещает выдачу предмета.

Может кто сталкивался с этой проблемой, какую сторону копать подскажет?

За ранее спасибо.
 
Run the GameServer in debug mode, add some breakpoints in the RequestWithDrawPremiumItem.java, enable stacktrace, and debug that bugger. :)
Just follow the stacktrace, step by step, until you figure out what triggers the message to appear in the client. It would be in one of the steps taken by the script. Then you figure out what causes the script to go down that rabbit hole and you fix it.
If the script jumps out of that java file, then you follow and add brackpoints in that other java file/method and repeat the process until you have everything figured out.


EDIT:

By the looks of it, it is one of these two checks:

1683235798618.png
 
Последнее редактирование:
Ну навтыкай как минимум в пакет выводов в консоль данных на разных этапах в пакете, чтобы понять на каком этапе спотыкается
А так пакет вроде правильный - у меня вот он тоже
Java:
package l2p.gameserver.network.c2s;

import l2p.gameserver.config.OtherConfig;
import l2p.gameserver.holders.items.PremiumItem;
import l2p.gameserver.model.Player;
import l2p.gameserver.network.components.SystemMsg;
import l2p.gameserver.network.s2c.ActionFail;
import l2p.gameserver.network.s2c.ExGetPremiumItemList;
import l2p.gameserver.network.s2c.ExGoodsInventoryResult;
import l2p.gameserver.utils.ItemUtils;

public final class RequestWithdrawPremiumItem extends L2GameClientPacket
{
    private int _uid;
    private int _objectId;
    private long _count;

    @Override
    protected void readImpl()
    {
        _uid = readD();
        _objectId = readD();
        _count = readQ();
    }

    @Override
    protected void runImpl()
    {
        Player player = getClient().getActiveChar();

        if (player == null)
            return;

        if (player.isActionsDisabled() || player.isInGoodsInventory())
        {
            player.sendPacket(ActionFail.STATIC);
            return;
        }

        if (_count <= 0 || player.getObjectId() != _objectId || player.getPremiumItems().isEmpty())
        {
            player.sendPacket(ActionFail.STATIC);
            return;
        }

        if (!ItemUtils.checkInventory(player, false))
        {
            player.sendPacket(SystemMsg.YOU_CANNOT_RECEIVE_THE_VITAMIN_ITEM_BECAUSE_YOU_HAVE_EXCEED_YOUR_INVENTORY_WEIGHT_OR_QUANTITY_LIMIT);
            return;
        }

        if (player.isInTrade())
        {
            player.sendPacket(SystemMsg.YOU_CANNOT_RECEIVE_A_VITAMIN_ITEM_DURING_AN_EXCHANGE);
            return;
        }

        if (player.isInPrivateStore())
        {
            player.sendPacket(SystemMsg.YOU_CANNOT_RECEIVE_BECAUSE_THE_PRIVATE_SHOP_OR_WORKSHOP_IS_IN_PROGRESS);
            return;
        }

        PremiumItem item = player.getPremiumItems().getItem(_uid);

        if (item == null || item.getCount() < _count)
        {
            player.sendPacket(ActionFail.STATIC);
            return;
        }

        player.setInGoodsInventory(true);

        try
        {
            ItemUtils.addItem(player, item.getItemId(), _count);
            player.getPremiumItems().updateItem(_uid, item.getCount() - _count);
        }
        catch (Exception e)
        {}
        finally
        {
            player.setInGoodsInventory(false);
        }

        if (player.getPremiumItems().isEmpty())
            player.sendPacket(SystemMsg.THERE_ARE_NO_MORE_VITAMIN_ITEMS_TO_BE_FOUND);
        else
            player.sendPacket(new ExGetPremiumItemList(player));

        if (OtherConfig.GOODS_INVENTORY_ENABLED)
            player.sendPacket(ExGoodsInventoryResult.CHANGED);
    }
}
я сам правда этим вариантом не пользуюсь - вместо этого GoodsInventory использую, т.к. он более функциональный.
Но возможно возможность его включать в последних хрониках выпилили - я по крайней мере не проверял
ну и я не уверен что оно в мобиусе вобще реализовано, т.к. на оффе вроде чисто в корее этот инвентарь когда-то юзался для доставки предметов купленных за реал.
 
Последнее редактирование:
Game Server console is clear, no problem.
Ok, I comment this checks and then check
Посмотреть вложение 52079
char_id проверьте, у меня он всегда равен 0 при расшифровке пакета.

Код:
    @Override
    public void readImpl() {
        _itemId = readInt();
        readInt(); // 0x00
        _itemCount = readLong();
    }

вот так должно быть. Дальше сам
 
Код:
    @Override
    public void readImpl() {
        _itemId = readInt();
        readInt(); // 0x00
        _itemCount = readLong();
    }

this is how it should be. Further by myself
It is the same, you just don't have the charId field set up, which is the same as removing all parts of the code that use charId.
 
Думаю не стоит отключать проверку чара на object_id, может поможет переделать значение на Long. позже проверю
 
Кароче танцы с бубнами помогли ... такой вариант рабочий
Java:
public class RequestWithDrawPremiumItem implements ClientPacket
{
    private int _itemNum;
    // private int _charId;
    private long _itemCount;
   
    @Override
    public void read(ReadablePacket packet)
    {
        _itemNum = packet.readInt();
        packet.readInt(); // 0x00
        _itemCount = packet.readLong();
    }
   
    @Override
    public void run(GameClient client)
    {
        final Player player = client.getPlayer();
        if ((player == null) || (_itemCount <= 0))
        {
            return;
        }
        // else if (player.getObjectId() != _charId)
        // {
        // Util.handleIllegalPlayerAction(player, "[RequestWithDrawPremiumItem] Incorrect owner, Player: " + player.getName(), Config.DEFAULT_PUNISH);
        // return;
        // }
        else if (player.getPremiumItemList().isEmpty())
        {
            Util.handleIllegalPlayerAction(player, "[RequestWithDrawPremiumItem] Player: " + player.getName() + " try to get item with empty list!", Config.DEFAULT_PUNISH);
            return;
        }
        else if ((player.getWeightPenalty() >= 3) || !player.isInventoryUnder90(false))
        {
            player.sendPacket(SystemMessageId.YOU_CANNOT_RECEIVE_THE_DIMENSIONAL_ITEM_BECAUSE_YOU_HAVE_EXCEED_YOUR_INVENTORY_WEIGHT_QUANTITY_LIMIT);
            return;
        }
        else if (player.isProcessingTransaction())
        {
            player.sendPacket(SystemMessageId.ITEMS_FROM_GAME_ASSISTANTS_CANNOT_BE_EXCHANGED);
            return;
        }
       
        final PremiumItem item = player.getPremiumItemList().get(_itemNum);
        if ((item == null) || (item.getCount() < _itemCount))
        {
            return;
        }
       
        final long itemsLeft = (item.getCount() - _itemCount);
        player.addItem("PremiumItem", item.getItemId(), _itemCount, player.getTarget(), true);
        if (itemsLeft > 0)
        {
            item.updateCount(itemsLeft);
            player.updatePremiumItem(_itemNum, itemsLeft);
        }
        else
        {
            player.getPremiumItemList().remove(_itemNum);
            player.deletePremiumItem(_itemNum);
        }
       
        if (player.getPremiumItemList().isEmpty())
        {
            player.sendPacket(SystemMessageId.THERE_ARE_NO_MORE_DIMENSIONAL_ITEMS_TO_BE_FOUND);
        }
        else
        {
            player.sendPacket(new ExGetPremiumItemList(player));
        }
    }
}
 
Назад
Сверху Снизу