public static void CheckPendingItem(Mobile m) { List <Item> list; if (PendingItems.TryGetValue(m, out list)) { var index = list.Count; while (--index >= 0) { if (index >= list.Count) { continue; } var item = list[index]; if (item != null) { if (m.Backpack != null && m.Alive && m.Backpack.TryDropItem(m, item, false)) { if (item is IPromotionalToken && ((IPromotionalToken)item).ItemName != null) { // A token has been placed in your backpack. Double-click it to redeem your ~1_PROMO~. m.SendLocalizedMessage(1075248, ((IPromotionalToken)item).ItemName.ToString()); } else if (item.LabelNumber > 0 || item.Name != null) { var name = item.LabelNumber > 0 ? ("#" + item.LabelNumber) : item.Name; // Your purchase of ~1_ITEM~ has been placed in your backpack. m.SendLocalizedMessage(1156844, name); } else { // Your purchased item has been placed in your backpack. m.SendLocalizedMessage(1156843); } list.RemoveAt(index); } } else { list.RemoveAt(index); } } if (list.Count == 0 && PendingItems.Remove(m)) { list.TrimExcess(); } } }
public static void CheckPendingItem(Mobile m) { if (PendingItems == null) { return; } if (PendingItems.ContainsKey(m)) { var list = new List <Item>(PendingItems[m]); foreach (Item item in list) { if (item != null) { if (m.Backpack != null && m.Alive && m.Backpack.TryDropItem(m, item, false)) { if (item is IPromotionalToken && ((IPromotionalToken)item).ItemName != null) { m.SendLocalizedMessage(1075248, ((IPromotionalToken)item).ItemName.ToString()); // A token has been placed in your backpack. Double-click it to redeem your ~1_PROMO~. } else if (item.LabelNumber > 0 || item.Name != null) { m.SendLocalizedMessage(1156844, item.LabelNumber > 0 ? String.Format("#{0}", item.LabelNumber.ToString()) : item.Name); // Your purchase of ~1_ITEM~ has been placed in your backpack. } else { m.SendLocalizedMessage(1156843); // Your purchased item has been placed in your backpack. } PendingItems[m].Remove(item); } } } ColUtility.Free(list); if (PendingItems[m].Count == 0) { PendingItems.Remove(m); } } }