//this is used to withdraw based on a particular store entry, and specified parameters
        public static Item WithdrawByEntryType(Container pack, Type entrytype, int amount, object[] parameters)
        {
            //check if there are any BaseStoreKey or MasterItemStoreKey objects in the caster's backpack
            Item[] keysources = pack.FindItemsByType(new Type[] { typeof(BaseStoreKey), typeof(MasterItemStoreKey) });

            if (keysources == null || amount == 0)
            {
                return(null);
            }

            //go thru the list of found objects
            foreach (Item key in keysources)
            {
                //utilizes IItemStoreObject interface function, defined by keys
                if (key is IItemStoreObject)
                {
                    //scan this object for any usable candidates to withdraw from
                    StoreEntry entry = ((IItemStoreObject)key).FindEntryByEntryType(entrytype, amount, parameters);

                    if (entry != null)
                    {
                        Item item = entry.Withdraw(ref amount, true);

                        entry.RefreshParentGump();

                        pack.AddItem(_LastWithdrawn);

                        return(item);
                    }
                }
            }

            return(null);
        }
        public static bool CraftWithdraw(Container pack, Type[] types, int amount, bool getamountonly)
        {
            //check if there are any BaseStoreKey or MasterItemStoreKey objects in the caster's backpack
            Item[] keysources = pack.FindItemsByType(new Type[] { typeof(BaseStoreKey), typeof(MasterItemStoreKey) });

            if (keysources == null || types == null || amount == 0)
            {
                return(false);
            }

            //go thru the list of found objects
            foreach (Item key in keysources)
            {
                //utilizes IItemStoreObject interface function, defined by keys
                if (key is IItemStoreObject)
                {
                    //scan this object for any usable candidates to withdraw from
                    StoreEntry entry = ((IItemStoreObject)key).FindConsumableEntry(types, amount);

                    if (entry != null)
                    {
                        if (getamountonly)
                        {
                            _LastAmountCount = entry.Amount;
                        }
                        else if (entry.Amount < amount)
                        {
                            //don't do anything if there's not enough to work from
                            return(false);
                        }
                        else
                        {
                            //if a valid entry was found, withdraw it to the container

                            Console.WriteLine("trying to withdraw " + amount.ToString());
                            //doesn't work properly with unstackable items

                            //store the amount that needs to be withdrawn, and reset the amount that has been withdrawn
                            int amounttowithdraw = amount;
                            int amountwithdrawn  = 0;

                            //keep withdrawing until the desired amount has been taken out
                            while (amountwithdrawn < amounttowithdraw)
                            {
                                amount = amounttowithdraw - amountwithdrawn;

                                _LastWithdrawn = entry.Withdraw(ref amount);

                                amountwithdrawn += amount;

                                //if for some reason none was taken out, then exit
                                if (amount == 0)
                                {
                                    return(false);
                                }
                                pack.AddItem(_LastWithdrawn);
                            }
                            entry.RefreshParentGump();
                        }
                        return(true);
                    }
                }
            }

            //if nothing was found, return false
            return(false);
        }        //static CraftWithdraw
        //the master withdraw method
        public void WithdrawItem(Mobile from, int amount, int entryindex, bool makedeed, bool resend)
        {
            StoreEntry entry = null;

            try
            {
                entry = _StoreEntries[entryindex];
            }
            catch
            {
                from.SendMessage("invalid selection pressed.");
                return;
            }

            //make sure making deeds is being offered with this bitmask
            makedeed &= OfferDeeds;


            //special handling - for a ListEntry object, hitting withdraw is not intended to remove the object, but rather
            //bring up a gump showing the list contained within the ListEntry
            if (entry is ListEntry)
            {
                from.SendGump(new ListEntryGump(from, (ListEntry)entry));
                return;
            }

            //special handling - for a StashEntry object, hitting withdraw will bring up a gump showing the stash contained
            //within the StashEntry
            if (entry is StashEntry)
            {
                from.SendGump(new StashEntryGump(from, (StashEntry)entry));
                return;
            }

            if (entry.Amount > 0)
            {
                //check if they can afford a commodity deed
                if (makedeed && resend && !Banker.Withdraw(from, 5))
                {
                    from.SendMessage("you must have at least 5 gold in your bank to extract the resource into a commodity deed");
                    return;
                }

                if (BaseStoreKey.EmptyContents && entry.RequiresRecipient)
                {
                    Item recipient = entry.FindRecipient(from);

                    if (recipient != null)
                    {
                        if (entry.WithdrawTo(ref WithdrawAmount, recipient) == null)
                        {
                            from.SendMessage("Cannot withdraw that for some reason!");
                            return;
                        }
                    }
                    else
                    {
                        from.SendMessage("You do not have a container to store that.");
                        return;
                    }
                }
                else
                {
                    Item item = entry.Withdraw(ref WithdrawAmount, makedeed);

                    if (item == null)
                    {
                        from.SendMessage("there was an error creating that item.  Please page a GM!");
                        return;
                    }

                    from.AddToBackpack(item);
                }
            }
            else
            {
                from.SendMessage("you don't have any of that");
            }
        }