Exemple #1
0
        public void removeItem(L2Item item)
        {
            item.sql_delete();
            lock (Items)
                Items.Remove(item.ObjID);

            if (item.Template.Weight > 0)
            {
                _owner.updateWeight();
            }
        }
Exemple #2
0
        public void destroyItem(L2Item item, int count, bool msg, bool update)
        {
            InventoryUpdate iu = null;

            if (update)
            {
                iu = new InventoryUpdate();
            }

            SystemMessage sm = null;

            if (msg)
            {
                sm = new SystemMessage(count == 1 ? 302 : 301);
            }

            List <int> nulled = new List <int>();
            bool       nonstackmass = false; int iditem = 0;

            if (item.Template.isStackable())
            {
                if (item.Count > count)
                {
                    item.Count -= count;
                    if (update)
                    {
                        iu.addModItem(item);
                    }

                    item.sql_update();
                }
                else
                {
                    nulled.Add(item.ObjID);
                    if (update)
                    {
                        iu.addDelItem(item);
                    }

                    item.sql_delete();
                }

                if (msg)
                {
                    sm.addItemName(item.Template.ItemID);

                    if (count > 1)
                    {
                        sm.addNumber(count);
                    }
                }
            }
            else
            {
                if (count == 1)
                {
                    nulled.Add(item.ObjID);

                    if (update)
                    {
                        iu.addDelItem(item);
                    }

                    if (msg)
                    {
                        sm.addItemName(item.Template.ItemID);
                    }

                    item.sql_delete();
                }
                else
                {
                    nonstackmass = true;
                    iditem       = item.Template.ItemID;
                    nulled.Add(item.ObjID);
                    if (update)
                    {
                        iu.addDelItem(item);
                    }

                    item.sql_delete();
                }
            }

            lock (Items)
                foreach (int id in nulled)
                {
                    Items.Remove(id);
                }

            if (update)
            {
                _owner.sendPacket(iu);
            }

            if (msg)
            {
                if (nonstackmass)
                {
                    sm.addItemName(iditem);
                    sm.addNumber(count);
                }

                _owner.sendPacket(sm);
            }

            if (item.Template.Weight > 0)
            {
                _owner.updateWeight();
            }
        }