[Plus/Cloud/Osore] HideWired Command

HTheAlexitoH

New Member
Aug 28, 2016
3
2
Hi, I bring the HideWired code. In the steps that from one emu to another change anything, I will put different spoilers to facilitate everything.

The command hides the wireds of the room. If they enter a room with activated hirewired they will appear hidden. If someone does reload in the room, hidewired is set to 0 and the furnis will be visible. If someone does Floor, it will be the same.

<<<<< This paragraph is explained in the second answer, there is a translation error.

-All this in the emu, with the Microsoft Visual Studio program (latest versions recommended)-

1- Go to emu\HabboHotel\Rooms\Chat\Commands\User and we created a file called HideWiredCommand.cs with the following code:

using System;
using System.Linq;
using System.Text;
using System.Collections.Generic;
using Cloud.Communication.Packets.Outgoing.Inventory.Furni;
using System.Globalization;
using Cloud.Database.Interfaces;
using Cloud.Communication.Packets.Outgoing;
using Cloud.HabboHotel.Items;
using Cloud.Communication.Packets.Outgoing.Rooms.Engine;
using Cloud.Communication.Packets.Outgoing.Rooms.Chat;

namespace Cloud.HabboHotel.Rooms.Chat.Commands.User
{
class HideWiredCommand : IChatCommand
{
public string PermissionRequired
{
get { return ""; }
}

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

public string Description
{
get { return "Oculta los Wired de la sala."; }
}

public void Execute(GameClients.GameClient Session, Rooms.Room Room, string[] Params)
{

if (!Room.CheckRights(Session, false, false))
{
Session.SendWhisper("¡No tienes permiso para ocultar wireds en esta sala!");
return;
}

Room.HideWired = !Room.HideWired;
if (Room.HideWired)
Session.SendWhisper("Los Wired han sido ocultados.");
else
Session.SendWhisper("Los Wired son ahora visibles.");

using (IQueryAdapter con = CloudServer.GetDatabaseManager().GetQueryReactor())
{
con.SetQuery("UPDATE `rooms` SET `hide_wired` = @enum WHERE `id` = @id LIMIT 1");
con.AddParameter("enum", CloudServer.BoolToEnum(Room.HideWired));
con.AddParameter("id", Room.Id);
con.RunQuery();
}

List<ServerPacket> list = new List<ServerPacket>();

list = Room.HideWiredMessages(Room.HideWired);

Room.SendMessage(list);


}
}
}
using System;
using System.Linq;
using System.Text;
using System.Collections.Generic;
using Plus.Communication.Packets.Outgoing.Inventory.Furni;
using System.Globalization;
using Plus.Database.Interfaces;
using Plus.Communication.Packets.Outgoing;
using Plus.HabboHotel.Items;
using Plus.Communication.Packets.Outgoing.Rooms.Engine;
using Plus.Communication.Packets.Outgoing.Rooms.Chat;

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

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

public string Description
{
get { return "Oculta los Wired de la sala."; }
}

public void Execute(GameClients.GameClient Session, Rooms.Room Room, string[] Params)
{

if (!Room.CheckRights(Session, false, false))
{
Session.SendWhisper("¡No tienes permiso para ocultar wireds en esta sala!");
return;
}

Room.HideWired = !Room.HideWired;
if (Room.HideWired)
Session.SendWhisper("Los Wired han sido ocultados.");
else
Session.SendWhisper("Los Wired son ahora visibles.");

using (IQueryAdapter con = HabboEnvironment.GetDatabaseManager().GetQueryReactor())
{
con.SetQuery("UPDATE `rooms` SET `hide_wired` = @enum WHERE `id` = @id LIMIT 1");
con.AddParameter("enum", HabboEnvironment.BoolToEnum(Room.HideWired));
con.AddParameter("id", Room.Id);
con.RunQuery();
}

List<ServerPacket> list = new List<ServerPacket>();

list = Room.HideWiredMessages(Room.HideWired);

Room.SendMessage(list);


}
}
}

2- In the previous folder, we opened CommandMananger.cs.

We look for the next line:
this.Register("lay", new LayCommand());

and below it we add:
this.Register("hidewired", new HideWiredCommand());

3- We search the file 'GetRoomEntryDataEvent.cs' situated in emu\Communication\Packets\Incoming\Rooms\Engine

We look for the following code:

if (!Room.GetRoomUserManager().AddAvatarToRoom(Session))
{
Room.GetRoomUserManager().RemoveUserFromRoom(Session, false, false);
return;//TODO: Remove?
}

and below it, we add:

Room.SendObjects(Session);
if (Room.HideWired && Room.CheckRights(Session, true, false))
Session.SendMessage(new RoomNotificationComposer("furni_placement_error", "message", "El wired está oculto en la sala."));

4- Go to emu\Communication\Packets\Incoming\Rooms\Furni\Wired and open SaveWiredConfigEvent.cs

We are looking for:

int ItemId = Packet.PopInt();

We add below:

Session.SendMessage(new HideWiredConfigComposer());

5- Go to ObjetsComposer.cs emu\Communication\Packets\Outgoing\Rooms\Engine

Look:

List<Item> l = new List<Item>();

Add below:

if (Room.HideWired)
{
for (int i = 0; i < Objects.Count(); i++)
{
Item it = Objects;
if (it == null)
continue;

if (it.IsWired)
continue;

l.Add(it);
}
Objects = l.ToArray();
base.WriteInteger(Objects.Length);
for (int i = 0; i < Objects.Count(); i++)
{
Item Item = Objects;
WriteFloorItem(Item, Convert.ToInt32(Item.UserID));
}
}


6- Go to emu\Communication\Packets\Outgoing\Rooms\Furni\Wired and we created a file called 'HideWiredConfigComposer.cs' whose code is:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Cloud.Communication.Packets.Outgoing.Rooms.Furni.Wired
{
class HideWiredConfigComposer : ServerPacket
{
public HideWiredConfigComposer()
: base(ServerPacketHeader.HideWiredConfigMessageComposer)
{
}
}
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Plus.Communication.Packets.Outgoing.Rooms.Furni.Wired
{
class HideWiredConfigComposer : ServerPacket
{
public HideWiredConfigComposer()
: base(ServerPacketHeader.HideWiredConfigMessageComposer)
{
}
}
}

7- Go to emu\HabboHotel\Rooms and open room.cs

Search:

public int IdleTime { get; set; }

and we add below:

private bool _hideWired;

We are looking for:

this.Landscape = Data.Landscape;

Below, we add:

this._hideWired = Data.HideWired;

Look for:

public List<string> WordFilterList
{
get { return this._wordFilterList; }
set { this._wordFilterList = value; }
}

Above of that code, we add:

public List<ServerPacket> HideWiredMessages(bool hideWired)
{
List<ServerPacket> list = new List<ServerPacket>();
Item[] items = this.GetRoomItemHandler().GetFloor.ToArray();
if (hideWired)
{
for (int i = 0; i < items.Count(); i++)
{
Item item = items;
if (!item.IsWired)
continue;
list.Add(new ObjectRemoveComposer(item, 0));
}
}
else
{
for (int i = 0; i < items.Count(); i++)
{
Item item = items;
if (!item.IsWired)
continue;
list.Add(new ObjectAddComposer(item, this));
}
}
return list;
}

public bool HideWired
{
get { return this._hideWired; }
set { this._hideWired = value; }
}


8- In that same folder, we open RoomData.cs

Search:

public bool PetMorphsAllowed;

Below, add:

public bool HideWired;

Search:

this.PetMorphsAllowed = CloudServer.EnumToBool(Row["pet_morphs_allowed"].ToString());

Below, we add:

this.HideWired = CloudServer.EnumToBool(Row["hide_wired"].ToString());

9- In that same folder, we open RoomItemHandling.cs

Look for:

if (newItem)
if (Item.IsWired)

if (Item.IsWired)
{

Below, we add:

if (_room.HideWired)
{
_room.HideWired = false;
Session.SendWhisper("El Wired está oculto.");
_room.SendMessage(_room.HideWiredMessages(false));
}

10- We go to our database and execute the following SQL code:

ALTER TABLE rooms ADD COLUMN hide_wired enum('0','1') NOT NULL DEFAULT '0';

Once ready, we compile and it should work. All the credits of codes to their respective authors (I do not know authorship).

If it has served you, all comments are useful to continue contributing things to this community ^^
 
Last edited:

ZaneyRetros

i am dead
Jul 27, 2015
211
105
Great work, will be helpful to a lot of people as a lot of Hotel Owners are looking for this command. However, just a suggestion wouldn't it be better for it to not reset when the room is unloaded or reloaded.

Regards,
Zane
 

HTheAlexitoH

New Member
Aug 28, 2016
3
2
Great work, will be helpful to a lot of people as a lot of Hotel Owners are looking for this command. However, just a suggestion wouldn't it be better for it to not reset when the room is unloaded or reloaded.

Regards,
Zane

I think my translation was erroneous. Only hidewired is reset to 0 when u used command ":reload" or ":floor". If you restart the room, the command will continue to work.
 

HTheAlexitoH

New Member
Aug 28, 2016
3
2
i can't find "List<Item> l = new List<Item>();" in objectscomposer in the 5th step
My ObjectsComposer:
Code:
using System;
using System.Linq;
using System.Text;
using System.Collections.Generic;

using Cloud.Utilities;
using Cloud.HabboHotel.Rooms;
using Cloud.HabboHotel.Items;
using Cloud.HabboHotel.Groups;
using Cloud.HabboHotel.Users;

namespace Cloud.Communication.Packets.Outgoing.Rooms.Engine
{
    class ObjectsComposer : ServerPacket
    {
        public ObjectsComposer(Item[] Objects, Room Room)
            : base(ServerPacketHeader.ObjectsMessageComposer)
        {
            base.WriteInteger(1);
            base.WriteInteger(Room.OwnerId);
            base.WriteString(Room.OwnerName);

            List<Item> l = new List<Item>();
            if (Room.HideWired)
            {
                for (int i = 0; i < Objects.Count(); i++)
                {
                    Item it = Objects[i];
                    if (it == null)
                        continue;

                    if (it.IsWired)
                        continue;

                    l.Add(it);
                }
                Objects = l.ToArray();
                base.WriteInteger(Objects.Length);
                for (int i = 0; i < Objects.Count(); i++)
                {
                    Item Item = Objects[i];
                    WriteFloorItem(Item, Convert.ToInt32(Item.UserID));
                }
            }
            else
            {
                base.WriteInteger(Objects.Length);
                for (int i = 0; i < Objects.Count(); i++)
                {
                    Item Item = Objects[i];
                    WriteFloorItem(Item, Convert.ToInt32(Item.UserID));
                }
            }
        }

        private void WriteFloorItem(Item Item, int UserID)
        {
            base.WriteInteger(Item.Id);
            base.WriteInteger(Item.GetBaseItem().SpriteId);
            base.WriteInteger(Item.GetX);
            base.WriteInteger(Item.GetY);
            base.WriteInteger(Item.Rotation);
            base.WriteString(String.Format("{0:0.00}", TextHandling.GetString(Item.GetZ)));
            base.WriteString(String.Empty);

            if (Item.LimitedNo > 0)
            {
                base.WriteInteger(1);
                base.WriteInteger(256);
                base.WriteString(Item.ExtraData);
                base.WriteInteger(Item.LimitedNo);
                base.WriteInteger(Item.LimitedTot);
            }
            else if (Item.Data.InteractionType == InteractionType.FX_PROVIDER)
            {
                base.WriteInteger(0);
                base.WriteInteger(1);
                base.WriteInteger(1);
                base.WriteString("effectId");
                base.WriteString(Item.ExtraData);
            }
            else if (Item.Data.InteractionType == InteractionType.PINATA)
            {
                base.WriteInteger(0);
                base.WriteInteger(7);
                base.WriteString("6");
                if (Item.ExtraData.Length <= 0) base.WriteInteger(0);
                else base.WriteInteger(int.Parse(Item.ExtraData));
                base.WriteInteger(100);
            }
            else if (Item.Data.InteractionType == InteractionType.PINATATRIGGERED)
            {
                base.WriteInteger(0);
                base.WriteInteger(7);  //
                base.WriteString("0");
                if (Item.ExtraData.Length <= 0) base.WriteInteger(0);
                else base.WriteInteger(int.Parse(Item.ExtraData));
                base.WriteInteger(1);
            }
            else if (Item.Data.InteractionType == InteractionType.MAGICEGG)
            {
                base.WriteInteger(0);
                base.WriteInteger(7);
                base.WriteString(Item.ExtraData);
                if (Item.ExtraData.Length <= 0)
                {
                    base.WriteInteger(0);
                }
                else
                {
                    base.WriteInteger(int.Parse(Item.ExtraData));
                }
                base.WriteInteger(23);
            }
            else if (Item.Data.InteractionType == InteractionType.MAGICCHEST)
            {
                base.WriteInteger(0);
                base.WriteInteger(7);
                base.WriteString(Item.ExtraData);
                if (Item.ExtraData.Length <= 0)
                {
                    base.WriteInteger(0);
                }
                else
                {
                    base.WriteInteger(int.Parse(Item.ExtraData));
                }
                base.WriteInteger(1);
            }
            else
            {
                ItemBehaviourUtility.GenerateExtradata(Item, this);
            }

            base.WriteInteger(-1); // to-do: check
            base.WriteInteger((Item.GetBaseItem().Modes > 1) ? 1 : 0);
            base.WriteInteger(UserID);
        }
    }
}

Search where you do not have it and add part of the code of my page.

You can probably find
Code:
private void WriteFloorItem(Item Item, int UserID)

And put the code of the 5th step, but adding (above all that)
Code:
List<Item> l = new List<Item>();
 

Users who are viewing this thread

Top