コード例 #1
0
        public override void RunImpl()
        {
            L2Player player = _client.CurrentPlayer;

            if (player.TradeState < 3) // умник
            {
                player.SendActionFailed();
                return;
            }

            if (player.EnchantState != 0)
            {
                player.SendActionFailed();
                return;
            }

            if (player.Requester == null)
            {
                player.SendMessage("Your trade requestor has logged off.");
                player.SendActionFailed();
                player.TradeState = 0;
                return;
            }

            if ((player.TradeState == 4) || (player.Requester.TradeState == 4)) // подтвердил уже
            {
                player.SendSystemMessage(SystemMessage.SystemMessageId.CannotAdjustItemsAfterTradeConfirmed);
                player.SendActionFailed();
                return;
            }

            L2Item item = player.Inventory.GetItemByObjectId(_sId);

            if (item == null)
            {
                player.SendActionFailed();
                return;
            }

            if (_num > item.Count)
            {
                _num = item.Count;
            }

            if (!item.Template.Stackable && (_num > 1))
            {
                _num = 1;
            }

            int numInList  = player.AddItemToTrade(item.ObjId, _num);
            int numCurrent = item.Count - numInList;

            player.SendPacket(new TradeOwnAdd(item, numInList));
            player.Requester.SendPacket(new TradeOtherAdd(item, numInList));

            byte action = 2; //mod, 2-del

            if (item.Template.Stackable)
            {
                action = (byte)(numCurrent < 1 ? 2 : 3);
            }

            player.SendPacket(new TradeUpdate(item, numCurrent, 0));
        }
コード例 #2
0
        public override void run()
        {
            L2Player player = Client.CurrentPlayer;

            if (player.TradeState < 3)// умник
            {
                player.sendActionFailed();
                return;
            }

            if (player.EnchantState != 0)
            {
                player.sendActionFailed();
                return;
            }

            if (player.requester == null)
            {
                player.sendMessage("Your trade requestor has logged off.");
                player.sendActionFailed();
                player.TradeState = 0;
                return;
            }

            if (player.TradeState == 4 || player.requester.TradeState == 4) // подтвердил уже
            {
                player.sendSystemMessage(122);                              //You may no longer adjust items in the trade because the trade has been confirmed.
                player.sendActionFailed();
                return;
            }

            L2Item item = player.Inventory.getByObject(sID);

            if (item == null)
            {
                player.sendActionFailed();
                return;
            }

            if (num < 0)
            {
                num = 1;
            }

            if (num > item.Count)
            {
                num = item.Count;
            }

            if (!item.Template.isStackable() && num > 1)
            {
                num = 1;
            }

            long numInList  = player.AddItemToTrade(item.ObjID, num);
            long numCurrent = item.Count - numInList;

            player.sendPacket(new TradeOwnAdd(item, numInList));
            player.requester.sendPacket(new TradeOtherAdd(item, numInList));

            byte action = 2; //mod, 2-del

            if (item.Template.isStackable())
            {
                action = 3;
                if (numCurrent < 1)
                {
                    action = 2;
                }
            }

            player.sendPacket(new TradeUpdate(item, numCurrent, action));
        }