Друзья подскажиоте что у меня не так с пакетами!
бай лист
PHP код:
protected final void writeImpl()
{
writeC(0x07);
writeQ(_money); // current money
writeD(_listId);
if(_Buylist == null)
{
writeH(0);
}
else
{
writeH(_Buylist.size());
for(TradeItem item : _Buylist)
{
//writeH(item.getItem().getType1()); // item type1
writeD(item.getObjectId());
writeD(item.getItemId());
writeQ(item.getCurrentValue()); // max amount of items that a player can buy at a time (with this itemid)
writeH(item.getItem().getType2ForPackets()); // item type2
writeH(0); // getCustomType1?
writeD(item.getItem().getBodyPart()); // rev 415 slot 0006-lr.ear 0008-neck 0030-lr.finger 0040-head 0080-?? 0100-l.hand 0200-gloves 0400-chest 0800-pants 1000-feet 2000-?? 4000-r.hand 8000-r.hand
writeH(item.getEnchantLevel()); // enchant level
writeH(0); // getCustomType1?
writeH(0); // unknown
writeQ((long) (item.getOwnersPrice() * (1 + _TaxRate)));
writeItemElements(item);
}
}
if(_SellList == null)
{
writeH(0);
}
else
{
writeH(_SellList.size());
for(TradeItem item : _SellList)
{
//writeH(item.getItem().getType1()); // item type1
writeD(item.getObjectId());
writeD(item.getItemId());
writeQ(item.getCurrentValue()); // max amount of items that a player can buy at a time (with this itemid)
writeH(item.getItem().getType2ForPackets()); // item type2
writeH(0); // getCustomType1?
writeD(item.getItem().getBodyPart()); // rev 415 slot 0006-lr.ear 0008-neck 0030-lr.finger 0040-head 0080-?? 0100-l.hand 0200-gloves 0400-chest 0800-pants 1000-feet 2000-?? 4000-r.hand 8000-r.hand
writeH(item.getEnchantLevel()); // enchant level
writeH(0); // getCustomType1?
writeH(0); // unknown
writeQ((long) (item.getOwnersPrice() * (1 + _TaxRate)));
writeItemElements(item);
}
}
if(_RefundList == null)
{
writeH(0);
}
else
{
writeH(_RefundList.size());
for(TradeItem item : _RefundList)
{
writeD(item.getObjectId());
writeD(item.getItemId());
writeQ(item.getCurrentValue()); // max amount of items that a player can buy at a time (with this itemid)
writeH(item.getItem().getType2ForPackets()); // item type2
writeH(0); // getCustomType1?
writeH(item.getEnchantLevel()); // enchant level
writeH(0); // getCustomType1?
writeH(0); // unknown //
writeQ((long) (item.getOwnersPrice() * (1 + _TaxRate)));
writeItemElements(item);
}
}
}
селл лист
PHP код:
protected final void writeImpl()
{
writeC(0x06);
writeQ(_money); // current money
writeD(_listId);
if(sellList == null)
{
writeH(0);
}
else
{
writeH(sellList .size());
for(L2ItemInstance item : sellList )
{
//writeH(item.getItem().getType1()); // item type1
writeD(item.getObjectId());
writeD(item.getItemId());
writeQ(item.getCount()); // max amount of items that a player can buy at a time (with this itemid)
writeH(item.getItem().getType2ForPackets()); // item type2
writeH(0x00); // getCustomType1?
writeD(item.getItem().getBodyPart()); // rev 415 slot 0006-lr.ear 0008-neck 0030-lr.finger 0040-head 0080-?? 0100-l.hand 0200-gloves 0400-chest 0800-pants 1000-feet 2000-?? 4000-r.hand 8000-r.hand
writeH(item.getEnchantLevel()); // enchant level
writeH(0x00); // getCustomType1?
writeH(item.getCustomType2());
writeQ(item.getItem().getReferencePrice()/2);
writeItemElements(item);
}
}
}
ExBuySellList
PHP код:
protected final void writeImpl()
{
writeC(EXTENDED_PACKET);
writeH(0xB7);
writeD(0x00);
writeQ(_money); // current money
writeD(_listId);
if(_Buylist == null)
writeH(0);
else
{
writeH(_Buylist.size());
for(TradeItem item : _Buylist)
{
writeD(item.getObjectId());
writeD(item.getItemId());
writeQ(item.getCurrentValue()); // max amount of items that a player can buy at a time (with this itemid)
writeD(0x00);
writeH(item.getItem().getType2ForPackets()); // item type2
writeH(0x00);
writeH(item.getCustomType1()); // getCustomType1?
writeD(item.getItem().getBodyPart()); // rev 415 slot 0006-lr.ear 0008-neck 0030-lr.finger 0040-head 0080-?? 0100-l.hand 0200-gloves 0400-chest 0800-pants 1000-feet 2000-?? 4000-r.hand 8000-r.hand
writeH(item.getEnchantLevel()); // enchant level
writeH(item.getCustomType2());
writeD(0x00);// Augmentation Id
writeD(-1);// Mana
writeD(0x00);// Shadow Life Time
writeItemElements(item);
writeEnchantEffect(item);
writeQ((long) (item.getOwnersPrice() * (1 + _TaxRate)));
}
}
getClient().sendPacket(new SellList(done, _SellList, _RefundList));
}
уже всё перепробовал ничё не получаеться!
Добавлено через 3 часа 20 минут
вот разобраный пакет ExBuySellList
PHP код:
package l2open.gameserver.serverpackets;
import l2open.gameserver.TradeController.NpcTradeList;
import l2open.gameserver.model.L2Player;
import l2open.gameserver.model.TradeItem;
import l2open.gameserver.model.items.Inventory;
import l2open.gameserver.model.items.L2ItemInstance;
import l2open.util.GArray;
import java.util.TreeSet;
import java.util.concurrent.ConcurrentLinkedQueue;
public class ExBuySellList extends L2GameServerPacket
{
private int _listId;
private byte done;
private final GArray<TradeItem> _Buylist;
private final TreeSet<L2ItemInstance> _SellList;
private final ConcurrentLinkedQueue<L2ItemInstance> _RefundList;
private long _money;
private double _TaxRate = 0;
public ExBuySellList(NpcTradeList Buylist, L2Player activeChar, double taxRate)
{
if(Buylist != null)
{
_listId = Buylist.getListId();
_Buylist = cloneAndFilter(Buylist.getItems());
activeChar.setBuyListId(_listId);
}
else
_Buylist = null;
_money = activeChar.getAdena();
_TaxRate = taxRate;
_RefundList = activeChar.getInventory().getRefundItemsList();
_SellList = new TreeSet<L2ItemInstance>(Inventory.OrderComparator);
for(L2ItemInstance item : activeChar.getInventory().getItemsList())
if(item.getItem().isSellable() && item.canBeTraded(activeChar) && item.getReferencePrice() > 0)
_SellList.add(item);
}
public ExBuySellList done()
{
done = 1;
return this;
}
protected static GArray<TradeItem> cloneAndFilter(GArray<TradeItem> list)
{
if(list == null)
return null;
GArray<TradeItem> ret = new GArray<TradeItem>(list.size());
for(TradeItem item : list)
{
// А не пора ли обновить количество лимитированных предметов в трейд листе?
if(item.getCurrentValue() < item.getCount() && item.getLastRechargeTime() + item.getRechargeTime() <= System.currentTimeMillis() / 60000)
{
item.setLastRechargeTime(item.getLastRechargeTime() + item.getRechargeTime());
item.setCurrentValue(item.getCount());
}
if(item.getCurrentValue() == 0 && item.getCount() != 0)
continue;
ret.add(item);
}
return ret;
}
@Override
protected final void writeImpl()
{
writeC(EXTENDED_PACKET);
writeH(0xB7);
writeD(0x00); // BUY LIST TYPE
writeQ(_money); // current money
writeD(_listId);
writeD(0x00);
writeH(_Buylist.size());
for(TradeItem item : _Buylist)
{
writeD(item.getObjectId());
writeD(item.getItemId());
writeD(item.getEquipSlot());
writeQ(count);
writeH(item.getItem().getType2ForPackets()); // item type2
writeH(item.getCustomType1());
writeH(item.isEquipped() ? 1 : 0);
writeD(item.getBodyPart());
writeH(item.getEnchantLevel());
writeH(item.getCustomType2());
writeD(0x00);//(item.getAugmentationId());
writeD(-1);//(item.getShadowLifeTime());
writeD(0x00);//(item.getTemporalLifeTime());
writeH(0x01);
writeH(item.getAttackElement());
writeH(item.getAttackElementValue());
for (int i = 0; i < 6; i++)
writeH(item.getDeffAttr()[i]);
writeH(0);
writeH(0);
writeH(0);
writeQ((long) (item.getOwnersPrice() * (1. + _TaxRate)));
}
getClient().sendPacket(new SellList(done, _SellList, _RefundList));
}
}