Quote Originally Posted by Lightning Blade
Hey everyone, I though I would put this out there since I felt like contributing.

This tutorial will probably help you if you want to change the MSG_SAY. This tutorial specificly changes the color of specific player rank's messages.

My tutorial is also targeted at beginners.


-- Start of Tutorial --

Open your ChatHandler.cpp and find your way to
Code:
 std::string to, channel, msg;
We want to add another string variable at the end.
Code:
 std::string to, channel, msg, color;
Now find your way to the type switch ( There are more than 1, so use the info below to find the right one ). -- For people who search - switch (type)
Inside the switch you should see this IF STATEMENT.
Code:
if (type == CHAT_MSG_SAY)    
sender->Say(color + msg, Language(lang));
As a note, you can use the changes we're about to make, on these two ELSE IF STATEMENTS to accomplish the same result with those CHAT_MSG_TYPES.
Code:
else if (type == CHAT_MSG_EMOTE)
                sender->TextEmote(msg);

 else if (type == CHAT_MSG_YELL)
                sender->Yell(msg, Language(lang));
Back to the actual modification. Replace
Code:
if (type == CHAT_MSG_SAY)    
sender->Say(color + msg, Language(lang));
With
Code:
if (type == CHAT_MSG_SAY)
            {
                switch (sender->GetSession()->GetSecurity())
                {
                case SEC_PLAYER:
                    color = "";
                    break;

                case SEC_MODERATOR:
                    color = "";
                    break;

                case SEC_GAMEMASTER:
                    color = "";
                    break;

                case SEC_ADMINISTRATOR:
                    color = "";
                    break;
                }
                sender->Say(color + msg, Language(lang));
            }
Just change color = "";(Marked as brown) to have a value inside ""(Could be a color or a message like [VIP]), you can create any case you'd like as long as the SEC is valid .



Case Template
Code:
Case SEC_PLAYER:

break;
Now in this example I use the variable color that we made earlier to define what kind of text we want before the message, since this is a string, the name does not limit it and thereby we can conclude that you can write any message for it to output , for example [VIP].

All you have to do now is compile and it works .


-- Tutorial End --.

Credits: LightningBlade


› See More: C++ - Customizing MSG_SAY