public void MoveItems(Network.WorldClient client, string packet) { if (this.IsAlive) { try { this.ResetValidate(client); string data = packet.Substring(4); char typeMove = packet[3]; string[] itemsInfos = data.Split('|'); int itemID = int.Parse(itemsInfos[0]); int quantity = int.Parse(itemsInfos[1]); if (quantity <= 0) { return; } var item = client.Character.Items.GetItem(itemID); if (!ExchangeRestrictions.RestrictedItems.Contains(item.Template) || client.Account.AdminLevel > 0) { switch (typeMove) { case '+': ExchangeItem exchangedItem = null; if (HaveOneOfThisItem(client, item)) { exchangedItem = GetOneOfThisItem(client, item); if (exchangedItem != null) { exchangedItem.Add(quantity); } } else { if (quantity <= item.Quantity) { exchangedItem = new ExchangeItem(item, quantity); GetStackByOwner(client).Add(exchangedItem); } } client.Send("EMKO+" + exchangedItem.WItem.ID + "|" + exchangedItem.Quantity); GetOtherTrader(client).Send("EmKO+" + exchangedItem.WItem.ID + "|" + exchangedItem.Quantity + "|" + exchangedItem.WItem.Template + "|" + exchangedItem.WItem.Effects); break; case '-': if (HaveOneOfThisItem(client, item)) { var removedItem = GetOneOfThisItem(client, item); if (removedItem != null) { if (removedItem.Remove(quantity)) { client.Send("EMKO-" + removedItem.WItem.ID); this.GetOtherTrader(client).Send("EmKO-" + removedItem.WItem.ID); this.GetStackByOwner(client).Remove(removedItem); } else { client.Send("EMKO+" + removedItem.WItem.ID + "|" + removedItem.Quantity); GetOtherTrader(client).Send("EmKO+" + removedItem.WItem.ID + "|" + removedItem.Quantity + "|" + removedItem.WItem.Template + "|" + removedItem.WItem.Effects); } } } break; } } else { client.Action.SystemMessage("Impossible d'echanger cette objet ! Veuilliez contacter un administrateur si vous voulez faire echanger cette objet !"); } } catch (Exception e) { Utilities.ConsoleStyle.Error("Can't move items in exchange : " + e.ToString()); } } }
public void MoveCraftItem(Network.WorldClient client, string packet) { string data = packet.Substring(4); char typeMove = packet[3]; string[] itemsInfos = data.Split('|'); int itemID = int.Parse(itemsInfos[0]); int quantity = int.Parse(itemsInfos[1]); if (quantity <= 0) { return; } if (this.Items.Count > this.BaseSkill.GetJobCraftMax()) { return; } var item = client.Character.Items.GetItem(itemID); switch (typeMove) { case '+': ExchangeItem exchangedItem = null; if (HaveOneOfThisItem(client, item)) { exchangedItem = GetOneOfThisItem(client, item); if (exchangedItem != null) { exchangedItem.Add(quantity); } } else { if (quantity <= item.Quantity) { exchangedItem = new ExchangeItem(item, quantity); this.Items.Add(exchangedItem); } } client.Send("EMKO+" + exchangedItem.WItem.ID + "|" + exchangedItem.Quantity); break; case '-': if (HaveOneOfThisItem(client, item)) { var removedItem = GetOneOfThisItem(client, item); if (removedItem != null) { if (removedItem.Remove(quantity)) { client.Send("EMKO-" + removedItem.WItem.ID); this.Items.Remove(removedItem); } else { client.Send("EMKO+" + removedItem.WItem.ID + "|" + removedItem.Quantity); } } } break; } }