[RELEASE] [COMMAND] [PlusEMU] View Inventories

Damien

Don't need glasses if you can C#
Feb 26, 2012
425
638
This is a command I coded as a response to a help thread that was posted a few days ago which can be found !

The command enables you to view other players inventories through your own, while making sure items can't be placed, traded and exchanged in the marketplace. The idea for this command came from @JayCustom, so all credits go to him for this. Enjoy!

Image:
8Y0HlHCrPC.gif

Firstly create a new command and name the file "ViewInventoryCommand.cs" and copy and paste this code into the file:
Code:
using System;
using System.Linq;
using System.Text;
using System.Collections.Generic;

using Plus.HabboHotel.GameClients;
using Plus.Communication.Packets.Outgoing.Inventory.Furni;

namespace Plus.HabboHotel.Rooms.Chat.Commands.Administrator
{
    class ViewInventoryCommand : IChatCommand
    {
        public string PermissionRequired
        {
            get { return "command_viewinventory"; }
        }

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

        public string Description
        {
            get { return ""; }
        }

        public void Execute(GameClient Session, Room Room, string[] Params)
        {
            if (Session.GetHabbo().ViewInventory)
            {
                Session.SendMessage(new FurniListComposer(Session.GetHabbo().GetInventoryComponent().GetFloorItems().ToList(), Session.GetHabbo().GetInventoryComponent().GetWallItems()));
                Session.GetHabbo().ViewInventory = false;
                Session.SendWhisper("Inventory reverted back to your own.");
                return;
            }

            if (Params.Length == 1)
            {
                Session.SendWhisper("Please enter the username of the user you'd like to check inventory.");
                return;
            }

            GameClient TargetClient = PlusEnvironment.GetGame().GetClientManager().GetClientByUsername(Params[1]);
            if (TargetClient == null)
            {
                Session.SendWhisper("An error occoured whilst finding that user, maybe they're not online.");
                return;
            }

            if (TargetClient.GetHabbo() == null)
            {
                Session.SendWhisper("An error occoured whilst finding that user, maybe they're not online.");
                return;
            }
         
            Session.SendMessage(new FurniListComposer(TargetClient.GetHabbo().GetInventoryComponent().GetFloorItems().ToList(), TargetClient.GetHabbo().GetInventoryComponent().GetWallItems(), true));
            Session.GetHabbo().ViewInventory = true;

            Session.SendWhisper("Next time you open your inventory you'll see " + TargetClient.GetHabbo().Username + "'s inventory.");
        }
    }
}


Inside CommandManager.cs add these commands aswell as any variations of your choosing:
Code:
this._commands.Add("viewinventory", new ViewInventoryCommand());
            this._commands.Add("inv", new ViewInventoryCommand());


Inside FurniListComposer.cs, replace the code with this:
Code:
using System;
using System.Linq;
using System.Text;
using System.Collections.Generic;

using Plus.HabboHotel.Items;
using Plus.HabboHotel.Groups;
using Plus.HabboHotel.Users;
using Plus.HabboHotel.Catalog.Utilities;

namespace Plus.Communication.Packets.Outgoing.Inventory.Furni
{
    class FurniListComposer : ServerPacket
    {
        public FurniListComposer(List<Item> Items, ICollection<Item> Walls, bool StaffCheck = false)
            : base(ServerPacketHeader.FurniListMessageComposer)
        {
            base.WriteInteger(1);
            base.WriteInteger(1);

            base.WriteInteger(Items.Count + Walls.Count);
            foreach (Item Item in Items.ToList())
                WriteItem(Item, StaffCheck);

            foreach (Item Item in Walls.ToList())
                WriteItem(Item, StaffCheck);
        }

        private void WriteItem(Item Item, bool StaffCheck)
        {
            base.WriteInteger(Item.Id);
            base.WriteString(Item.GetBaseItem().Type.ToString().ToUpper());
            base.WriteInteger(Item.Id);
            base.WriteInteger(Item.GetBaseItem().SpriteId);
            ItemBehaviourUtility.GenerateExtradata(Item, this);
            base.WriteBoolean(StaffCheck ? false : Item.GetBaseItem().AllowEcotronRecycle);
            base.WriteBoolean(StaffCheck ? false : Item.GetBaseItem().AllowTrade);
            base.WriteBoolean(Item.LimitedNo == 0 ? Item.GetBaseItem().AllowInventoryStack : false);
            base.WriteBoolean(StaffCheck ? false : ItemUtility.IsRare(Item));
            base.WriteInteger(-1);//Seconds to expiration.
            base.WriteBoolean(true);
            base.WriteInteger(-1);//Item RoomId

            if (!Item.IsWallItem)
            {
                base.WriteString(string.Empty);
                base.WriteInteger(0);
            }
        }
    }
}
This is what stops the user, trading; selling or recycling any of the other users items.


Inside PlaceObjectEvent.cs under this line:
Code:
if (Session == null || Session.GetHabbo() == null || !Session.GetHabbo().InRoom)
                return;


Add this segment of code:
Code:
if (Session.GetHabbo().ViewInventory)
            {
                Session.SendMessage(new RoomNotificationComposer("furni_placement_error", "message", "This item doesn't belong to you. Are you currently viewing someone elses inventory?"));
                return;
            }


In Habbo.cs at the top add this:
Code:
private bool _ViewInventory;


Also in Habbo.cs in the Habbo method add this:
Code:
this._ViewInventory = false;


Finally in Habbo.cs at the bottom add this:
Code:
public bool ViewInventory
        {
            get { return this._ViewInventory; }
            set { this._ViewInventory = value; }
        }

And there you have it, if I've missed anything please post a comment bellow and I'll add it to the thread.
@GuruGuru, @JayCustom, @Core.
 

Mexicano

El Patrón
Aug 14, 2013
363
175
This right here is a high class release that will actually help retros. (Not just those little renames that just add sellroom/buyroom)
Fantastic release Damien, you never stop impressing people and i hope i have the luck to work with you again!
10/10 :D
 

JayC

Always Learning
Aug 8, 2013
5,493
1,398
Fucking Amazing :) Got that coded so quickly ! I have had this idea but never could be bothered to start it. This turned out great :D Great Job 10/10
 

GuruGuru

Member
Dec 1, 2016
52
3
This is really awesome! Would you mind being a little bit more descriptive on adding the last part below in Habbo.cs? Is it within the the brackets? If so which one? Is it within a method?
 
This is really awesome! Would you mind being a little bit more descriptive on adding the last part below in Habbo.cs? Is it within the the brackets? If so which one? Is it within a method?
So this was more obvious than I originally thought. #Noob, amazing release! YOU ARE KING!
 

Xuxu

Member
Nov 21, 2016
295
59
nice, though some people might not be thrilled to have people seeing what furni they have but this could be a good way to catch scammers in casinos
 

Damien

Don't need glasses if you can C#
Feb 26, 2012
425
638
nice, though some people might not be thrilled to have people seeing what furni they have but this could be a good way to catch scammers in casinos
It's used for moderation purposes, but could be used for casinos. And why wouldn't people be thrilled about other people seeing their virtual items on a virtual game?
 

Joe

Well-Known Member
Jun 10, 2012
4,088
1,915
If I remember, Sledmore was working on a bot that did this, you could check if the user actually has the item(s) in their inventory.
 

Core

Member
Nov 10, 2016
356
138
It's used for moderation purposes, but could be used for casinos. And why wouldn't people be thrilled about other people seeing their virtual items on a virtual game?
People tend to forget the virtual element of it or they act like they're richer than they actually are.
 

Damien

Don't need glasses if you can C#
Feb 26, 2012
425
638
If I remember, Sledmore was working on a bot that did this, you could check if the user actually has the item(s) in their inventory.
Not a bad idea actually.. expect a release for this tomorrow at some point haha. I like it.
 

Users who are viewing this thread

Top