Пример #1
0
 public void OnSupplyExchange(Packets.Client.SupplyExchange p)
 {
     if (this.Char.CurTarget == null)
     {
         return;
     }
     if (this.Char.CurTarget.type != ActorType.NPC)
     {
         return;
     }
     try
     {
         Npc npc = (Npc)this.Char.CurTarget.e;
         Packets.Server.SendSupplyResult p2 = new SagaMap.Packets.Server.SendSupplyResult();
         uint supplyID = p.GetSupplyID();
         if (!npc.SupplyMatrials.ContainsKey(supplyID) || !npc.SupplyProducts.ContainsKey(supplyID))
         {
             if (this.Char.GMLevel > 1)
             {
                 SendMessage("System", "Cannot find Supply items for supplyID:" + supplyID + " for this NPC!", SagaMap.Packets.Server.SendChat.MESSAGE_TYPE.SYSTEM_MESSAGE);
             }
             return;
         }
         if (!this.Char.inv.HasFreeSpace())
         {
             p2.SetResult(SagaMap.Packets.Server.SendSupplyResult.Results.NOT_ENOUGH_SPACE);
             this.netIO.SendPacket(p2, this.SessionID);
             return;
         }
         foreach (Packets.Server.SendSupplyList.SupplyItem i in npc.SupplyMatrials[supplyID])
         {
             if (npc.CountItem(this.Char, (int)i.itemID) < i.amount)
             {
                 p2.SetResult(SagaMap.Packets.Server.SendSupplyResult.Results.NOT_ENOUGH_SPACE);
                 this.netIO.SendPacket(p2, this.SessionID);
                 return;
             }
             npc.TakeItem(this.Char, (int)i.itemID, i.amount);
         }
         foreach (Packets.Server.SendSupplyList.SupplyItem i in npc.SupplyProducts[supplyID])
         {
             npc.GiveItem(this.Char, (int)i.itemID, i.amount);
         }
         p2.SetResult(SagaMap.Packets.Server.SendSupplyResult.Results.OK);
         this.netIO.SendPacket(p2, this.SessionID);
     }
     catch (Exception)
     {
     }
 }