public void OnSupplySelect(Packets.Client.SupplySelect 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.SendSupplyList p2 = new SagaMap.Packets.Server.SendSupplyList(); 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; } p2.SetActor(npc.Actor.id); p2.SetSupplyID(supplyID); p2.SetProducts(npc.SupplyProducts[supplyID]); p2.SetMatrial(npc.SupplyMatrials[supplyID]); this.netIO.SendPacket(p2, this.SessionID); npc.NPCChat(this.Char, 0); } catch (Exception) { } }
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) { } }