• Unfortunately, we have experienced significant hard drive damage that requires urgent maintenance and rebuilding. The forum will be a state of read only until we install our new drives and rebuild all the configurations needed. Please follow our Facebook page for updates, we will be back up shortly! (The forum could go offline at any given time due to the nature of the failed drives whilst awaiting the upgrades.) When you see an Incapsula error, you know we are in the process of migration.

How to make your own Mercury commands [NOOBFRIENDLY] [Examples]

Experienced Elementalist
Joined
Jul 1, 2012
Messages
232
Reaction score
37
Hi there RageZoners,
today I release a very simple guide on how to make your own custom commands.

Some requirements first,
Mercury hotel already set-up. I will not answer questions about how you can't set up your hotel.
Visual Studio

Where do I start?
First of all, where can you find all of your commands, and add your own.
This file is called ChatCommandHandler.cs and can be found in /HabboHotel/Misc/ in your source folder.
Open this file up with Visual Studio. As you scroll down you will find all your commands as you have now.

What next?
First you have to think about what your command will do. This is necessairy to know before you start making your command. Let's say our idea is very simple. The command is :like and the output is that the detonating user says "* I like it *". This is just a example - idea.

Writing your command part ONE (permission check)
In ChatCommandHandler.cs you see all commands, you are gonna write your own between existing commands.
Okay, now we now where to do it, how do I do it?
You start your command with case "command":,
so for us that'll be:
Code:
case "like":
If you want your commands to work with multiple inputs, just add such cases below. Like this:
Code:
case "like":
case "ilikeit":
Okay, so now we have started our command, let's go on.
Below your case you simply add a '{' to start your command. Below that we add the function to check if your player is allowed to perform this command. So that'll be
Code:
case "like":
case "ilikeit":
{
if (!this.Session.GetHabbo().GotCommand("like"));
below this we want to add what will happen if you do NOT have the fuse_cmd "like". Let's say we want the user to whisper "You can not perform this command" to himself. Therefor it'll be:
Code:
case "like":
case "ilikeit":
{
if (!this.Session.GetHabbo().GotCommand("like"));
{
this.Session.SendWhisper("You can not perform this command");
return true;
}
the return true; desides whether or not your user will say :like like a text or not. (this happens when return = false: )
We want our user JUST to whisper the text to itself, but NOT say :like, so we set return to true.

Writing your command part TWO (the fun part)
Now we have done our permissions, let's make your command do what you want it to do, in this case, that is making your user say "* I like it *". Below our permissions part we start with the check who is detonating the command, and if this player is in a valid room. Therefor we add
Code:
Room ourroom = MercuryEnvironment.GetGame().GetRoomManager().GetRoom(this.Session.GetHabbo().CurrentRoomId);
if (ourroom != null)
{
below our permissions check.

So now that's done we go to check who is detonating this command. Therefor we add
Code:
RoomUser ouruser = ourroom.GetRoomUserManager().GetRoomUserByHabbo(this.Session.GetHabbo().Id);
{

So now or code looks like this:
Code:
case "like":
case "ilikeit":
{
if (!this.Session.GetHabbo().GotCommand("like"));
{
this.Session.SendWhisper("You can not perform this command");
return true;
}
Room ourroom = MercuryEnvironment.GetGame().GetRoomManager().GetRoom(this.Session.GetHabbo().CurrentRoomId);
if (ourroom != null)
{
RoomUser ouruser = ourroom.GetRoomUserManager().GetRoomUserByHabbo(this.Session.GetHabbo().Id);
{
Perfect! Every check and other thing that should be done is done now. It's time to make the magic happen! In our case that's making your user say "* I like it *". Therefore we use "ouruser.Chat". This is how it looks:
Code:
ouruser.Chat(ouruser.GetClient(), "* I like it *", false, 0, 0);
You can play with this a little, you can edit the text as well as the bool after the text. (false or true), false means the user says the text, true means the user shouts the text. I think to say it looks nicer so we're gonna use that for now.
Below ouruser.Chat line, we're gonna have to return true; once again, so that you won't see ":like" after "* I like it *".
Now that's done, let's finish up our command by closing up with '}'s. Our command is now finished and looks like this:
Code:
                    case "like":
                    case "ilikeit":
                        {
                            if (!this.Session.GetHabbo().GotCommand("appelsap"))
                            {
                                SendChatMessage(this.Session, "You can not perform this command");
                                return false;
                            }
                            Room ourroom = MercuryEnvironment.GetGame().GetRoomManager().GetRoom(this.Session.GetHabbo().CurrentRoomId);
                            if (ourroom != null)
                            {
                                RoomUser ouruser = ourroom.GetRoomUserManager().GetRoomUserByHabbo(this.Session.GetHabbo().Id);
                                {
                                        ouruser.Chat(ouruser.GetClient(), "* I like it *", false, 0, 0);
                                        return true;
                                }
                            }
                            return true;
                        }

Debug your emulator now and let's test!
This is what it looks like:

Once again, the example I used is very basic, you can freely experiment with it as you want.

Extra
If you want to make your command work with a param input :)command PARAM) you can expirent with my own made provided command below: :)love username)
Code:
                    case "love":
                        
                            if (!this.Session.GetHabbo().GotCommand("love"))
                            {
                                SendChatMessage(this.Session, "You can not perform this command");
                                return true;
                            }
                            if ((Params[1] != null))
                            {
                                Room room17 = MercuryEnvironment.GetGame().GetRoomManager().GetRoom(this.Session.GetHabbo().CurrentRoomId);
                                if (room17 != null)
                                {
                                    RoomUser user13 = room17.GetRoomUserManager().GetRoomUserByHabbo(this.Session.GetHabbo().Id);
                                    {
                                        {
                                            user13.Chat(user13.GetClient(), "*| Loves " + Params[1] + " |*", false, 0, 0);//example command made by Weed aka AskethZ on ragezone
                                        }
                                        return true;
                                    }
                                }
                                return true;
                            }
                            this.Session.SendWhisper("You have to tell who you love. Example: :love Weed");
                            return true;

Don't forget!
I almost forgot to say this but if you make a command and use the check permissions system with "GotCommand" you have to add your command into fuse_cmds in your database. So for like and love that would be this query:
Code:
INSERT INTO `fuse_cmds` (`id`, `command`, `rank`, `params`, `description`) VALUES ('673', 'like', '1', NULL, 'I like it!'), ('501', 'love', '1', 'user', 'Love is in the air!');

Did this help you?
If it didn't, please reply with your bug and/or question.
If it did, likes would be appreciated.:blushing:


Loves,
AskethZ aka Weed
 
Elite Diviner
Joined
Aug 4, 2013
Messages
466
Reaction score
169
This is a great release for the people who have been commenting like crazy lately with requests for commands.
Great release​, I hope to see future tutorials from you regarding Mercury.
 
Experienced Elementalist
Joined
Jul 1, 2012
Messages
232
Reaction score
37
This is a great release for the people who have been commenting like crazy lately with requests for commands.
Great release​, I hope to see future tutorials from you regarding Mercury.

Thanks a lot!
What kind of Mercury tutorials would you want to see in the future? Or should I make a command making service? ;o
 
Elite Diviner
Joined
Aug 4, 2013
Messages
466
Reaction score
169
Thanks a lot!
What kind of Mercury tutorials would you want to see in the future? Or should I make a command making service? ;o
That's completely up to you. I don't have any personal suggestions for you regarding future releases either. If you make a command making service, stick with it. Everyone who ends up making a service thread for commands never fully gets all of the requests posted.

Goodluck, friend.
 
Experienced Elementalist
Joined
Jul 1, 2012
Messages
232
Reaction score
37
If you decide to, I wish you good luck!

I did a quick research. It's quite expensive :$. Perhaps when I quit school. I see you can make some nice money with it
 
Newbie Spellweaver
Joined
Jan 11, 2013
Messages
18
Reaction score
3
In mind, you can do some backdoors with that ;) Haha!
 
Back
Top