Aller au contenu
  • Veuillez ne pas poster de message pour but d'insulter, incitation à la haine, propos sexuels et tout autre qui ne respecte pas nos conditions générales !

[Plus/Cloud/Osore] HideWired Command


Alhxe

Messages recommandés

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.

 

-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:

 

CLOUD

Citation

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);


        }
    }
}

 


PLUS:

Citation

 


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:

Citation

this.Register("lay", new LayCommand());

 

and below it we add:

 

Citation

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:

 

Citation

if (!Room.GetRoomUserManager().AddAvatarToRoom(Session))


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

 

and below it, we add:

 

Citation

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:

Citation

int ItemId = Packet.PopInt();

 

We add below:

Citation

Session.SendMessage(new HideWiredConfigComposer());

 

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

 

Look:

Citation

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

 

Add below:

Citation

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:

 

CLOUD

 

Citation

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)
        {
        }
    }
}

 

 

PLUS

 

Citation

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:

 

Citation

public int IdleTime { get; set; }

 

and we add below:

 

Citation

private bool _hideWired;

 

We are looking for:

 

Citation

this.Landscape = Data.Landscape;

 

Below, we add:

 

Citation

this._hideWired = Data.HideWired;

 

Look for:

 

Citation

public List<string> WordFilterList


        {
            get { return this._wordFilterList; }
            set { this._wordFilterList = value; }
        }

 

Above of that code, we add:

 

Citation

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:

 

Citation

public bool PetMorphsAllowed;

 

Below, add:

 

Citation

public bool HideWired;

 

Search:

 

Citation

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

 

Below, we add:

 

Citation

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

 

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

 

Look for:

 

Citation

if (newItem)


                if (Item.IsWired)

                    if (Item.IsWired)
                    {

 

Below, we add:

 

Citation

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:
 

Citation

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 ^^

Modifié par Alhxe
Lien à poster
Partager sur d’autres sites

il y a 25 minutes, Pancani a dit :

Hi, I think this command was already shared

Thanks anyway for sharing ;) 

I searched for many places and in almost all there was no issue about it.

It also serves as a tutorial ^^

Lien à poster
Partager sur d’autres sites

  • 2 semaines plus tard...
  • Responsable modération

Where stick the code for the database ?

~ MatYouFR ~

 

+ French Player +

+ Player of Valorant, Battlefield 4 & 5, GTA 5, ETS 2, Rocket League +

+ Streamer on Twitch +

 

signature.png

Lien à poster
Partager sur d’autres sites

  • 1 mois plus tard...

Créer un compte ou se connecter pour commenter

Vous devez être membre afin de pouvoir déposer un commentaire

Créer un compte

Créez un compte sur notre communauté. C’est facile !

Créer un nouveau compte

Se connecter

Vous avez déjà un compte ? Connectez-vous ici.

Connectez-vous maintenant
×
×
  • Créer...