User Tag List

Results 1 to 2 of 2

Thread: C++ - Customizing MSG_SAY

  1. #1
    Exalted Member Lightning Blade's Avatar
    Join Date
    Aug 2013
    Posts
    152
    XP
    332,860
    Level
    119
    Thanks
    17
    Thanked 20 Times in 13 Posts

    C++ - Customizing MSG_SAY

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

    I hope you found this tutorial helpful. Regardless if you did or did not have a great day!.
    Last edited by Lightning Blade; 03-02-2015 at 02:45 PM.
    Achievements:
    Got a Sticky! Referrer Shopper 1 year registered Member Bad Seed Level XL Level C

  2. The Following 3 Users Say Thank You to Lightning Blade For This Useful Post:


  3. #2
    Exalted Member
    Join Date
    Dec 2013
    Location
    United Kingdom
    Posts
    291
    XP
    305,197
    Level
    116
    Thanks
    42
    Thanked 11 Times in 10 Posts
    Thing been changed in trinitycore, gotta try find the way lol
    Achievements:
    Member 1 year registered Level XL Level C
    warning

    Warning

    Don't look at my profile.




Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •