[PlusEMU] Trouble Getting :emptyitems To Not Delete LTD's

treebeard

Member
Jan 16, 2018
317
173
Helllo everyone,

I'm currently trying to get the command :emptyitems to not delete LTD's.
I have edited the function ClearItems() in InventoryComponent.cs to look like this:
Code:
public void ClearItems()
        {
            UpdateItems(true);

            using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.RunQuery("DELETE FROM items WHERE room_id='0' AND limited_stack = '0' AND user_id = " + _userId); //Do join
            }

            this._floorItems.Clear();
            this._wallItems.Clear();

            if (_client != null)
                _client.SendPacket(new FurniListUpdateComposer());
        }

This actually does work but not in a very nice way. What happens is the users inventory would be completely cleared until they logged out and back in, then the LTD's would appear in inventory again. I want it to just never show that the LTD's are deleted.

This is just a cheap fix I'm trying to implement till I can figure out how to get deleted LTD's to transfer to an account for re-use.

Any help is appreciated, thanks!

Edit: I realized I didn't include the actual code for emptyitems in case that helps.


Code:
using System;
using System.Linq;
using System.Text;
using System.Collections.Generic;
using Plus.Communication.Packets.Outgoing.Inventory.Furni;

namespace Plus.HabboHotel.Rooms.Chat.Commands.User
{
    class EmptyItems : IChatCommand
    {
        public string PermissionRequired
        {
            get { return "command_empty_items"; }
        }

        public string Parameters
        {
            get { return "%yes%"; }
        }

        public string Description
        {
            get { return "Is your inventory full? You can remove all items by typing this command."; }
        }

        public void Execute(GameClients.GameClient Session, Rooms.Room Room, string[] Params)
        {
            if (Params.Length == 1)
            {
                Session.SendNotification("Are you sure you want to clear your inventory? You will lose all the furniture!\n" +
                 "To confirm, type \":emptyitems yes\". \n\nOnce you do this, there is no going back!\n(If you do not want to empty it, just ignore this message!)\n\n" +
                 "PLEASE NOTE! If you have more than 3000 items, the hidden items will also be DELETED.");
                return;
            }
            else
            {
                if (Params.Length == 2 && Params[1].ToString() == "yes")
                {
                    Session.GetHabbo().GetInventoryComponent().ClearItems();
                    Session.SendNotification("Your inventory has been cleared!");   
                    return;
                }
                else if (Params.Length == 2 && Params[1].ToString() != "yes")
                {
                    Session.SendNotification("To confirm, you must type in :emptyitems yes");
                    return;
                }
            }
        }
    }
}
 

JayC

Always Learning
Aug 8, 2013
5,505
1,401
Code:
this._floorItems.Clear();

That empties the array of floor items inside the users inventories.
 
Update, Here is your Solution:

Code:
        public void ClearItems()
        {
            UpdateItems(true);

            using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
            {
               dbClient.RunQuery("DELETE FROM items WHERE room_id='0' AND limited_stack = '0' AND user_id = " + _userId)
            }

            this.removeItemsExceptLimited();
            this._wallItems.Clear();

            if (_client != null)
                _client.SendMessage(new FurniListUpdateComposer());
        }

        private void removeItemsExceptLimited()
        {
            Item itemRemoved;

            foreach (var item in this._floorItems)
                if (item.Value.LimitedNo == 0)
                    this._floorItems.TryRemove(item.Key, out itemRemoved);
        }
 

treebeard

Member
Jan 16, 2018
317
173
Code:
this._floorItems.Clear();

That empties the array of floor items inside the users inventories.
 
Update, Here is your Solution:

Code:
        public void ClearItems()
        {
            UpdateItems(true);

            using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
            {
               dbClient.RunQuery("DELETE FROM items WHERE room_id='0' AND limited_stack = '0' AND user_id = " + _userId)
            }

            this.removeItemsExceptLimited();
            this._wallItems.Clear();

            if (_client != null)
                _client.SendMessage(new FurniListUpdateComposer());
        }

        private void removeItemsExceptLimited()
        {
            Item itemRemoved;

            foreach (var item in this._floorItems)
                if (item.Value.LimitedNo == 0)
                    this._floorItems.TryRemove(item.Key, out itemRemoved);
        }
You indeed are the man! :up:
 

Users who are viewing this thread

Top