Coloured Usernames Release [PlusEmu]

Mikee

Active Member
Jul 8, 2017
162
102
Credits Go To @Jerry

Step 1. Make this Command
Code:
namespace Plus.HabboHotel.Rooms.Chat.Commands.User
{
    class ColouredChatCommand : IChatCommand
    {
        public string PermissionRequired => "command_setcolor";
        public string Parameters => "%color%";
        public string Description => "Set your chat color to whatever you want.";

        public void Execute(GameClients.GameClient Session, Rooms.Room Room, string[] Params)
        {
            string colorName = Params[1].ToLower();

            switch (colorName)
            {
                case "silver":
                    {
                        Session.GetHabbo().ChatColor = "#C0C0C0";
                        Session.SendWhisper($"Your chat color has been set to {colorName}");
                        break;
                    }
                case "grey":
                case "gray":
                    {
                        Session.GetHabbo().ChatColor = "#808080";
                        Session.SendWhisper($"Your chat color has been set to {colorName}");
                        break;
                    }
                case "default":
                case "none":
                case "off":
                case "black":
                    {
                        Session.GetHabbo().ChatColor = "#000000";
                        Session.SendWhisper("You have disabled your chat color");
                        break;
                    }
                case "red":
                    {
                        Session.GetHabbo().ChatColor = "#FF0000";
                        Session.SendWhisper($"Your chat color has been set to {colorName}");
                        break;
                    }
                case "maroon":
                    {
                        Session.GetHabbo().ChatColor = "#800000";
                        Session.SendWhisper($"Your chat color has been set to {colorName}");
                        break;
                    }
                case "yellow":
                    {
                        Session.GetHabbo().ChatColor = "#FFFF00";
                        Session.SendWhisper($"Your chat color has been set to {colorName}");
                        break;
                    }
                case "olive":
                    {
                        Session.GetHabbo().ChatColor = "#808000";
                        Session.SendWhisper($"Your chat color has been set to {colorName}");
                        break;
                    }
                case "lime":
                    {
                        Session.GetHabbo().ChatColor = "#00FF00";
                        Session.SendWhisper($"Your chat color has been set to {colorName}");
                        break;
                    }
                case "green":
                    {
                        Session.GetHabbo().ChatColor = "#008000";
                        Session.SendWhisper($"Your chat color has been set to {colorName}");
                        break;
                    }
                case "aqua":
                    {
                        Session.GetHabbo().ChatColor = "#00FFFF";
                        Session.SendWhisper($"Your chat color has been set to {colorName}");
                        break;
                    }
                case "teal":
                    {
                        Session.GetHabbo().ChatColor = "#008080";
                        Session.SendWhisper($"Your chat color has been set to {colorName}");
                        break;
                    }
                case "blue":
                    {
                        Session.GetHabbo().ChatColor = "#0000FF";
                        Session.SendWhisper($"Your chat color has been set to {colorName}");
                        break;
                    }
                case "navy":
                    {
                        Session.GetHabbo().ChatColor = "#000080";
                        Session.SendWhisper($"Your chat color has been set to {colorName}");
                        break;
                    }
                case "fuschia":
                    {
                        Session.GetHabbo().ChatColor = "#FF00FF";
                        Session.SendWhisper($"Your chat color has been set to {colorName}");
                        break;
                    }
                case "purple":
                    {
                        Session.GetHabbo().ChatColor = "#800080";
                        Session.SendWhisper($"Your chat color has been set to {colorName}");
                        break;
                    }
                default:
                    {
                        Session.SendWhisper($"The chat color {colorName} does not exist!");
                        break;
                    }
            }
        }
    }
}

Step 2.

Find Player Static Values in Habbo.cs
Below it put this...
Code:
public string ChatColor;

Step 3.

Go to RoomUser.Cs and add this method
Code:
 public void SendNameColourPacket()
         {
             if (IsBot || GetClient() == null || GetClient().GetHabbo() == null)
                 return;
             if (GetClient().GetHabbo().ChatColor == null || GetClient().GetHabbo().ChatColor == String.Empty)
                 return;
             if (GetClient().GetHabbo().ChatPreference)
                 return;
             string Username = "<font color='" + GetClient().GetHabbo().ChatColor + "'>" + GetClient().GetHabbo().Username + "</font>";

             if (GetRoom() != null)
                 GetRoom().SendPacket(new UserNameChangeComposer(RoomId, VirtualId, Username));

         }

Also add this method
Code:
  public void SendNamePacket()
        {
            if (IsBot || GetClient() == null || GetClient().GetHabbo() == null)
                return;

            string Username = GetClient().GetHabbo().Username;

            if (GetRoom() != null)
                GetRoom().SendPacket(new UserNameChangeComposer(RoomId, VirtualId, Username));
        }

Now in that same class replace
Code:
            if (GetClient().GetHabbo().TentId > 0)
            {
                mRoom.SendToTent(GetClient().GetHabbo().Id, GetClient().GetHabbo().TentId, Packet);

                Packet = new WhisperComposer(this.VirtualId, "[Tent Chat] " + Message, 0, Colour);

                List<RoomUser> ToNotify = mRoom.GetRoomUserManager().GetRoomUserByRank(2);

                if (ToNotify.Count > 0)
                {
                    foreach (RoomUser user in ToNotify)
                    {
                        if (user == null || user.GetClient() == null || user.GetClient().GetHabbo() == null ||
                            user.GetClient().GetHabbo().TentId == GetClient().GetHabbo().TentId)
                        {
                            continue;
                        }

                        user.GetClient().SendPacket(Packet);
                    }
                   
                }
            }
            else
            {


                foreach (RoomUser User in mRoom.GetRoomUserManager().GetRoomUsers().ToList())
                {
                    if (User == null || User.GetClient() == null || User.GetClient().GetHabbo() == null || User.GetClient().GetHabbo().GetIgnores().IgnoredUserIds().Contains(mClient.GetHabbo().Id))
                        continue;

                    if (mRoom.chatDistance > 0 && Gamemap.TileDistance(this.X, this.Y, User.X, User.Y) > mRoom.chatDistance)
                        continue;

                    User.GetClient().SendPacket(Packet);
                }

            }
...

With
Code:
            if (GetClient().GetHabbo().TentId > 0)
            {
                mRoom.SendToTent(GetClient().GetHabbo().Id, GetClient().GetHabbo().TentId, Packet);

                Packet = new WhisperComposer(this.VirtualId, "[Tent Chat] " + Message, 0, Colour);

                List<RoomUser> ToNotify = mRoom.GetRoomUserManager().GetRoomUserByRank(2);

                if (ToNotify.Count > 0)
                {
                    foreach (RoomUser user in ToNotify)
                    {
                        if (user == null || user.GetClient() == null || user.GetClient().GetHabbo() == null ||
                            user.GetClient().GetHabbo().TentId == GetClient().GetHabbo().TentId)
                        {
                            continue;
                        }

                        user.GetClient().SendPacket(Packet);
                    }
                   
                }
            }
            else
            {
                SendNameColorPacket();

                foreach (RoomUser User in mRoom.GetRoomUserManager().GetRoomUsers().ToList())
                {
                    if (User == null || User.GetClient() == null || User.GetClient().GetHabbo() == null || User.GetClient().GetHabbo().GetIgnores().IgnoredUserIds().Contains(mClient.GetHabbo().Id))
                        continue;

                    if (mRoom.chatDistance > 0 && Gamemap.TileDistance(this.X, this.Y, User.X, User.Y) > mRoom.chatDistance)
                        continue;

                    User.GetClient().SendPacket(Packet);
                }
                SendNamePacket();
            }
 
Last edited:

Berk

berkibap#4233
Developer
Oct 17, 2015
863
190
Thanks for this, any chances I can make only a part coloured? Like username will be
[RANKNAME] Username :
And RANKNAME will be based on colour from database.
 

Mikee

Active Member
Jul 8, 2017
162
102
Thanks for this, any chances I can make only a part coloured? Like username will be
[RANKNAME] Username :
And RANKNAME will be based on colour from database.
sure but icba to code it properly,
Code:
public void SendNameColorPacket()
        {
         
            if (IsBot || GetClient() == null || GetClient().GetHabbo() == null)
                return;

            //if (GetClient().GetHabbo().ChatColor == null || GetClient().GetHabbo().ChatColor == String.Empty)
              //  return;

            if (GetClient().GetHabbo().ChatPreference)
                return;

            using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
            {
           
                dbClient.SetQuery("SELECT `rank_tag` FROM `users` WHERE username = '" + GetClient().GetHabbo().Username + "'");
                this.rankTag = dbClient.GetString();
            }
         

            if (this.rankTag != String.Empty)
            {
               
                string Username = "<font color='" + GetClient().GetHabbo().ChatColor + "'> [" + this.rankTag + "] " + GetClient().GetHabbo().Username + "</font>";
                GetRoom().SendPacket(new UserNameChangeComposer(RoomId, VirtualId, Username));
                return;
            }
            else
            {
                string Username = "<font color='" + GetClient().GetHabbo().ChatColor + "'>" + GetClient().GetHabbo().Username + "</font>";
                GetRoom().SendPacket(new UserNameChangeComposer(RoomId, VirtualId, Username));
                return;
            }
        }

I DO NOT RECOMMEND USING THIS CODE
It will flood ur SQL Server.

What you should do is store the RankTag as a session variable in Habbo.cs then call it.

I released this bit as an example as to how it could be done.
 
Last edited:

Berk

berkibap#4233
Developer
Oct 17, 2015
863
190
It's a shame you didn't release the rainbow name function.
Anyway, good release nevertheless.
you can do it by css.
Code:
gradient( linear, left top, right top, color-stop(0, #f22), color-stop(0.15, #f2f), color-stop(0
.3, #22f), color-stop(0.45, #2ff), color-stop(0.6, #2f2),color-stop(0.75, #2f2), color-stop(0.9, #ff2), color-stop(1, #f22) );
 

Mikee

Active Member
Jul 8, 2017
162
102
It's a shame you didn't release the rainbow name function.
Anyway, good release nevertheless.
All u had to do was ask xD

Code:
 public static string GenerateRainbowText(string Name)
        {
            StringBuilder NewName = new StringBuilder();

            string[] Colours = { "FF0000", "FFA500", "FFFF00", "008000", "0000FF", "800080" };

            int Count = 0;
            int Count2 = 0;
            while (Count < Name.Length)
            {
                NewName.Append("<font color='" + Colours[Count2] + "'>" + Name[Count] + "</font>");

                Count++;
                Count2++;

                if (Count2 >= 6)
                    Count2 = 0;
            }

            return NewName.ToString();
        }

I would say it'd be best to put this in the setcolorcommand then generate a case for rainbow and return this function for that case.

Or maybe you'll find a better way to implement :p
 
Nov 27, 2014
238
35
o thats kinda cool
 
How could I call it? Username = GenerateRainbowText(Session.GetHabbo().Username)? Cause when I do it that way, it keeps my username as black.
 

Mikee

Active Member
Jul 8, 2017
162
102
Just replace ur SendNameColorPacket with this

Code:
 public void SendNameColorPacket()
        {
          
            if (IsBot || GetClient() == null || GetClient().GetHabbo() == null)
                return;

            //if (GetClient().GetHabbo().ChatColor == null || GetClient().GetHabbo().ChatColor == String.Empty)
              //  return;

            if (GetClient().GetHabbo().ChatPreference)
                return;      
        
            if (GetClient().GetHabbo().ChatColor == "Rainbow")
            {
                string Username = GenerateRainbowText(GetClient().GetHabbo().Username);
                GetRoom().SendPacket(new UserNameChangeComposer(RoomId, VirtualId, Username));
                return;
            }

            else if (this.rankTag != String.Empty)
            {
                
                string Username = "<font color='" + GetClient().GetHabbo().ChatColor + "'> [" + this.rankTag + "] " + GetClient().GetHabbo().Username + "</font>";
                GetRoom().SendPacket(new UserNameChangeComposer(RoomId, VirtualId, Username));
                return;
            }
            else
            {
                string Username = "<font color='" + GetClient().GetHabbo().ChatColor + "'>" + GetClient().GetHabbo().Username + "</font>";
                GetRoom().SendPacket(new UserNameChangeComposer(RoomId, VirtualId, Username));
                return;
            }
        }

go to ColouredChatCommand and add this

Code:
 case "rainbow":
                    {
                        Session.GetHabbo().ChatColor = "Rainbow";
                        break;
                    }

Please don't tell me that rank tags dont work for rainbow text, because ik they don't. Challenge urself a little bit and add it in if u'd like

Also add the generaterainbowtext code somewhere in RoomUser.cs
 
Last edited:
Nov 27, 2014
238
35
oki, I figured it out. But when I type, my name is still black - but when I display it with Old Chat (where it shows all HTML with name colours) it's clearly inputting the chat colours.
never mind - problem: there's no # before the newname append thng
 
Last edited:

Mikee

Active Member
Jul 8, 2017
162
102
I can't find player static values in habbo.cs, is it player values?
its just a comment, where u assign that variable inevitably doesn't matter just somewhere near the top like public string username, place it near that.
 

j0ker

$client = socket_accept($sock);
Dec 29, 2010
78
22
What the fuck mike, this is from my fucking emulator...... Are you fucking kidding me? This is some bullshit, claiming ur release when u leaked it from my emu. Fuck off Mike.
 
Last edited:

Mikee

Active Member
Jul 8, 2017
162
102
What the fuck mike, this is from my fucking emulator...... Are you fucking kidding me? This is some bullshit, claiming ur release when u leaked it from my emu. Fuck off Mike.
Credits to Jerry was clearly stated. Getting this working for u inspired me to release it. Dont say this is ur work lulz,
 

j0ker

$client = socket_accept($sock);
Dec 29, 2010
78
22
Credits to Jerry was clearly stated. Getting this working for u inspired me to release it. Dont say this is ur work lulz,
Um, that code was from a previous build of my emu, you then made it work for a new production and emu, then released all of the chatcolor code on devbest. Da fuck are you talking about.
 

Mikee

Active Member
Jul 8, 2017
162
102
Um, that code was from a previous build of my emu, you then made it work for a new production and emu, then released all of the chatcolor code on devbest. Da fuck are you talking about.
lol, this is jerrys work that happened to be on ur emulator, a spanish one, and a bunch others ive come across. i decided to release it since ive seen people ask for it in the past.

Z2Iz1gIiQ_6G7Wobk-DAEQ.png

gbvbau
 

j0ker

$client = socket_accept($sock);
Dec 29, 2010
78
22
Broken image, and again, that is my fucking code from my fucking emu, I even said, don't release anything I'm trusting you, and you said I won't blah blah blah and yet you fucking did to make yourself look useful, fuck you dude. I'm done with this thread, hope ur release gets ur cocksucked and made urself look good bud or whatever you were trying to do. You've lost my respect. Remember who bought you the Account Upgrade for devbest. Fuckin sad dude. -
 

Users who are viewing this thread

Top