longtianchi

Member
Code:
        public static Dictionary<Mobile, List<Item>> m = new Dictionary<Mobile, List<Item>>();
        private static void PowerGump11_OnCommand(CommandEventArgs e)
        {
            if (!m.ContainsKey(e.Mobile))
                m.Add(e.Mobile, e.Mobile.Items);
            Container pack = new Backpack();
            pack.Movable = false;
            e.Mobile.Items =  new List<Item>();
            e.Mobile.AddItem(pack);
        }
        private static void PowerGump12_OnCommand(CommandEventArgs e)
        {
            foreach (Item item in e.Mobile.Items)
            {
                item.Delete();
            }
            e.Mobile.Items = m[e.Mobile];
        }

This can generate new backpacks, but will not be replaced by old ones.
 
Mobile has a Backpack property that you can access to get reference to the backpack (if one exists, if not you'll get null so remember to check for that), you can then use that reference to remove(delete, move location ext) the old pack, once it's removed it should be easy to add the new pack, but you will want to remove the old one first.
 
I got a script that is correct for 2 places where items needs to be stored.

PlayerMobile.backpack.items and PlayerMobile.items
 
I'm not confused about the mobile class, I'm confused about where the player's items are stored, because they're not in one place, and I ignored the layer relationship at first.

Now I have solved this problem.
Code:
            //BackPack Items Recordset
            if (m_Owner.Backpack != null)
                for (int i = 0; i < m_Owner.Backpack.Items.Count; ++i)
                    m_BackpackContent.Add(new ItemStoreInfo(m_Owner.Backpack.Items[i], m_Owner.Backpack.Items[i].Location));

            //Equipped ItemsRecordset
            foreach (Item item in m_Owner.Items)
                if (item.Layer != Layer.Bank && item.Layer != Layer.Backpack && item.Layer != Layer.Hair && item.Layer != Layer.FacialHair)
                    m_EquippedItems.Add(item);
 
Last edited:

Active Shards

Donations

Total amount
$0.00
Goal
$1,000.00
Back