Example #1
0
        // 08 03
        public void OnTradeItem(SagaMap.Packets.Client.GetTradeItem p)
        {
            if (this.state != SESSION_STATE.MAP_LOADED)
            {
                return;
            }
            if (this.Char.trading != Trading.TRADING)
            {
                return;
            }
            byte Tradeslot = p.GetSlot();
            byte ItemIndex = p.GetItem();
            byte quantity  = p.GetQuantity();
            byte status;
            //Lookup trade items information from character's inventory
            Item TradeItem = this.Char.inv.GetItem(CONTAINER_TYPE.INVENTORY, ItemIndex);

            if (quantity > TradeItem.stack)
            {
                quantity = TradeItem.stack;
            }
            TradeItem = new Item(TradeItem.id, TradeItem.creatorName, TradeItem.durability, TradeItem.stack);// make sure it's a different instance than the old one
            if (this.Char.trading == Trading.TRADING)
            {
                if (!TradeItem.tradeAble)
                {
                    this.SendTradeResult(TradeResults.NOT_TRADEABLE);
                    status = 9;
                }
                else
                {
                    status = 0;

                    // Add item to chars list of items to trade
                    try
                    {
                        TradeItems.Add(TradeItem, quantity);
                    }
                    catch
                    {
                    }
                    Logger.ShowInfo("Trade item added", null);
                    //Send info about item to clients
                    Packets.Server.TradeItem sendPacket = new SagaMap.Packets.Server.TradeItem();
                    sendPacket.SetTradeSlot(Tradeslot);
                    sendPacket.SetItemIndex(ItemIndex);
                    sendPacket.SetQuantity(quantity);
                    sendPacket.SetStatus(status);
                    netIO.SendPacket(sendPacket, this.SessionID);

                    ActorPC target = (ActorPC)map.GetActor(this.Char.TradeTarget);
                    if (target == null)
                    {
                        return;
                    }
                    target.e.OnTradeItem(Tradeslot, TradeItem);
                }
            }
        }
Example #2
0
        // 08 03
        public void OnTradeItem(SagaMap.Packets.Client.GetTradeItem p)
        {
            if (this.state != SESSION_STATE.MAP_LOADED) return;
            if (this.Char.trading != Trading.TRADING) return;
            byte Tradeslot = p.GetSlot();
            byte ItemIndex = p.GetItem();
            byte quantity = p.GetQuantity();
            byte status;
            //Lookup trade items information from character's inventory
            Item TradeItem = this.Char.inv.GetItem(CONTAINER_TYPE.INVENTORY, ItemIndex);
            if (quantity > TradeItem.stack) quantity = TradeItem.stack;
            TradeItem = new Item(TradeItem.id, TradeItem.creatorName, TradeItem.durability, TradeItem.stack);// make sure it's a different instance than the old one
            if (this.Char.trading == Trading.TRADING)
            {
                if (!TradeItem.tradeAble)
                {
                    this.SendTradeResult(TradeResults.NOT_TRADEABLE);
                    status = 9;
                }
                else
                {
                    status = 0;

                    // Add item to chars list of items to trade
                    try
                    {
                        TradeItems.Add(TradeItem, quantity);
                    }
                    catch
                    {
                    }
                    Logger.ShowInfo("Trade item added", null);
                    //Send info about item to clients
                    Packets.Server.TradeItem sendPacket = new SagaMap.Packets.Server.TradeItem();
                    sendPacket.SetTradeSlot(Tradeslot);
                    sendPacket.SetItemIndex(ItemIndex);
                    sendPacket.SetQuantity(quantity);
                    sendPacket.SetStatus(status);
                    netIO.SendPacket(sendPacket, this.SessionID);

                    ActorPC target = (ActorPC)map.GetActor(this.Char.TradeTarget);
                    if (target == null) return;
                    target.e.OnTradeItem(Tradeslot, TradeItem);
                }
            }
        }