Fully Functional Stack Height Command

Txc

Member
Jan 26, 2017
84
45
Hey devbest, today I'm finally releasing a command that everyone should have coded into their emulators. It's more or less essential for building on a hotel because everyone complains about stacktiles. As well as a lot of people have the buggy versions of stackheight coded into your emulators, so I'll bring you mine

Go to habbo.cs and search for "private int _currentRoomId;". Under that put this line
Code:
public double ForceHeight;

Next go to the folder path HabboHotel>Rooms>Chat>Commands>User and create StackHeightCommand.cs and paste this code into the class
Code:
using System;
using System.Linq;
using System.Text;
using System.Collections.Generic;
using Plus.Communication.Packets.Outgoing.Inventory.Furni;
using System.Globalization;

namespace Plus.HabboHotel.Rooms.Chat.Commands.User
{
    class StackHeightCommand : IChatCommand
    {
        public string PermissionRequired
        {
            get
            {
                return "command_stack_height";
            }
        }
        public string Parameters
        {
            get
            {
                return "%message%";
            }
        }
        public string Description
        {
            get
            {
                return "Set the Stack Height.";
            }
        }
        public void Execute(GameClients.GameClient Session, Rooms.Room Room, string[] Params)
        {

            if (!Room.CheckRights(Session, false, false))
            {
                Session.SendNotification("You don't have permission for the command `stack_height`");
                return;
            }

            RoomUser user = Room.GetRoomUserManager().GetRoomUserByHabbo(Session.GetHabbo().Id);
            if (user == null)
            {
                Session.SendNotification("User not found.");
                return;
            }


            if (Params.Length < 2)
            {
                Session.SendWhisper("Please enter a numeric value or type ':sh -' to turn it off");
                return;
            }

            if (Params[1] == "-")
            {
                Session.SendWhisper("Stack Height Disabled");
                Session.GetHabbo().ForceHeight = -1;
                return;
            }

            double value;
            bool checkIfParsable = Double.TryParse(Params[1], out value);
            if (checkIfParsable == false)
            {
                Session.SendWhisper("Please enter a numeric value or type ':sh -' to turn it off");
                return;
            }

            
            double HeightValue = Convert.ToDouble(Params[1]);
            if (HeightValue < 0 || HeightValue > 100)
            {
                Session.SendWhisper("Please enter a value between 0 and 100");
                return;
            }

            Session.GetHabbo().ForceHeight = HeightValue;
            Session.SendWhisper("Stack Height Is: " + Convert.ToString(HeightValue));
        }
    }
}

Next go to GetRoomEntryDataEvent and near the bottom add this line
Code:
 //force the stackheight to be set off by default
            Session.GetHabbo().ForceHeight = -1;

Now we make our edits to RoomItemHandler.cs (This is the last class we will be editing)

Find this line
Code:
// Start calculating new Z coordinate
            Double newZ = _room.GetGameMap().Model.SqFloorHeight[newX, newY];
Under it add
Code:
 if (Session.GetHabbo().ForceHeight != -1)
            {
                newZ = Session.GetHabbo().ForceHeight;
            }
Next find
Code:
 if (Item.Rotation != newRot && Item.GetX == newX && Item.GetY == newY)
                    newZ = Item.GetZ;
Replace it with this
Code:
if (Item.Rotation != newRot && Item.GetX == newX && Item.GetY == newY)
                    if (Session.GetHabbo().ForceHeight != -1)
                    {
                        newZ = Session.GetHabbo().ForceHeight;
                    }
                    else
                    {
                        newZ = Item.GetZ;
                    }
Finally find this
Code:
        // Are there any higher objects in the stack!?
                foreach (Item I in ItemsComplete.ToList())
                {
                    if (I == null)
                        continue;
                    if (I.Id == Item.Id)
                        continue;

                    if (I.GetBaseItem().InteractionType == InteractionType.STACKTOOL)
                    {                       
                        newZ = I.GetZ;
                        break;
                    }
                    if (I.TotalHeight > newZ)
                    {
                        newZ = I.TotalHeight;
                    }
                }
Replacing it with this
Code:
                // Are there any higher objects in the stack!?
                foreach (Item I in ItemsComplete.ToList())
                {
                    if (I == null)
                        continue;
                    if (I.Id == Item.Id)
                        continue;

                    if (I.GetBaseItem().InteractionType == InteractionType.STACKTOOL && Session.GetHabbo().ForceHeight == -1)
                    {                       
                        newZ = I.GetZ;
                        break;
                    }
                    if (I.TotalHeight > newZ && Session.GetHabbo().ForceHeight != -1)
                    {
                        newZ = Session.GetHabbo().ForceHeight;
                    }
                    else if (I.TotalHeight > newZ && Session.GetHabbo().ForceHeight == -1)
                    {
                        newZ = I.TotalHeight;
                    }
                }

Don't forget to reference your command the way you want it in commandmanager.cs like one or more of these examples
Code:
this.Register("fh", new StackHeightCommand());
            this.Register("sh", new StackHeightCommand());
            this.Register("setsh", new StackHeightCommand());

In the database table Permissions_Commands make sure you add the entry for command_stack_height with rank 1 as the default permission.

And there you have it, a stack height that works by default requiring no edits to the code I provided. Enjoy!
 

alek980

New Member
Oct 7, 2019
27
1
Hey devbest, today I'm finally releasing a command that everyone should have coded into their emulators. It's more or less essential for building on a hotel because everyone complains about stacktiles. As well as a lot of people have the buggy versions of stackheight coded into your emulators, so I'll bring you mine

Go to habbo.cs and search for "private int _currentRoomId;". Under that put this line
Code:
public double ForceHeight;

Next go to the folder path HabboHotel>Rooms>Chat>Commands>User and create StackHeightCommand.cs and paste this code into the class
Code:
using System;
using System.Linq;
using System.Text;
using System.Collections.Generic;
using Plus.Communication.Packets.Outgoing.Inventory.Furni;
using System.Globalization;

namespace Plus.HabboHotel.Rooms.Chat.Commands.User
{
    class StackHeightCommand : IChatCommand
    {
        public string PermissionRequired
        {
            get
            {
                return "command_stack_height";
            }
        }
        public string Parameters
        {
            get
            {
                return "%message%";
            }
        }
        public string Description
        {
            get
            {
                return "Set the Stack Height.";
            }
        }
        public void Execute(GameClients.GameClient Session, Rooms.Room Room, string[] Params)
        {

            if (!Room.CheckRights(Session, false, false))
            {
                Session.SendNotification("You don't have permission for the command `stack_height`");
                return;
            }

            RoomUser user = Room.GetRoomUserManager().GetRoomUserByHabbo(Session.GetHabbo().Id);
            if (user == null)
            {
                Session.SendNotification("User not found.");
                return;
            }


            if (Params.Length < 2)
            {
                Session.SendWhisper("Please enter a numeric value or type ':sh -' to turn it off");
                return;
            }

            if (Params[1] == "-")
            {
                Session.SendWhisper("Stack Height Disabled");
                Session.GetHabbo().ForceHeight = -1;
                return;
            }

            double value;
            bool checkIfParsable = Double.TryParse(Params[1], out value);
            if (checkIfParsable == false)
            {
                Session.SendWhisper("Please enter a numeric value or type ':sh -' to turn it off");
                return;
            }

           
            double HeightValue = Convert.ToDouble(Params[1]);
            if (HeightValue < 0 || HeightValue > 100)
            {
                Session.SendWhisper("Please enter a value between 0 and 100");
                return;
            }

            Session.GetHabbo().ForceHeight = HeightValue;
            Session.SendWhisper("Stack Height Is: " + Convert.ToString(HeightValue));
        }
    }
}

Next go to GetRoomEntryDataEvent and near the bottom add this line
Code:
 //force the stackheight to be set off by default
            Session.GetHabbo().ForceHeight = -1;

Now we make our edits to RoomItemHandler.cs (This is the last class we will be editing)

Find this line
Code:
// Start calculating new Z coordinate
            Double newZ = _room.GetGameMap().Model.SqFloorHeight[newX, newY];
Under it add
Code:
 if (Session.GetHabbo().ForceHeight != -1)
            {
                newZ = Session.GetHabbo().ForceHeight;
            }
Next find
Code:
 if (Item.Rotation != newRot && Item.GetX == newX && Item.GetY == newY)
                    newZ = Item.GetZ;
Replace it with this
Code:
if (Item.Rotation != newRot && Item.GetX == newX && Item.GetY == newY)
                    if (Session.GetHabbo().ForceHeight != -1)
                    {
                        newZ = Session.GetHabbo().ForceHeight;
                    }
                    else
                    {
                        newZ = Item.GetZ;
                    }
Finally find this
Code:
        // Are there any higher objects in the stack!?
                foreach (Item I in ItemsComplete.ToList())
                {
                    if (I == null)
                        continue;
                    if (I.Id == Item.Id)
                        continue;

                    if (I.GetBaseItem().InteractionType == InteractionType.STACKTOOL)
                    {                      
                        newZ = I.GetZ;
                        break;
                    }
                    if (I.TotalHeight > newZ)
                    {
                        newZ = I.TotalHeight;
                    }
                }
Replacing it with this
Code:
                // Are there any higher objects in the stack!?
                foreach (Item I in ItemsComplete.ToList())
                {
                    if (I == null)
                        continue;
                    if (I.Id == Item.Id)
                        continue;

                    if (I.GetBaseItem().InteractionType == InteractionType.STACKTOOL && Session.GetHabbo().ForceHeight == -1)
                    {                      
                        newZ = I.GetZ;
                        break;
                    }
                    if (I.TotalHeight > newZ && Session.GetHabbo().ForceHeight != -1)
                    {
                        newZ = Session.GetHabbo().ForceHeight;
                    }
                    else if (I.TotalHeight > newZ && Session.GetHabbo().ForceHeight == -1)
                    {
                        newZ = I.TotalHeight;
                    }
                }

Don't forget to reference your command the way you want it in commandmanager.cs like one or more of these examples
Code:
this.Register("fh", new StackHeightCommand());
            this.Register("sh", new StackHeightCommand());
            this.Register("setsh", new StackHeightCommand());

In the database table Permissions_Commands make sure you add the entry for command_stack_height with rank 1 as the default permission.

And there you have it, a stack height that works by default requiring no edits to the code I provided. Enjoy!

I'm having issues with this, did all of the above but still does not reckognize sh, rh og setsh as a command. Please help
 

ZaneyRetros

i am dead
Jul 27, 2015
211
105
yes the client is not recognizing it as a command instead it blurts out into text :setsh
In the database table permissions_commands, make sure you add the entry for command_stack_height with rank 1 as the default permission and then :update permissions and try it.
 

ManIron

Member
Jun 1, 2018
135
22
You must be registered for see images attach


restarted emu but this tutorial is for adding a room for all users to enter when open client? the hotel 1st room.


You must be registered for see images attach


how to reference here?
 
Last edited:

Users who are viewing this thread

Top