User Tag List

Page 3 of 3 FirstFirst 1 2 3
Results 15 to 20 of 20

Thread: Add tag before player name (chat)

  1. #15
    Original Poster
    Member
    Join Date
    Jul 2016
    Posts
    33
    XP
    370
    Level
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I spent hours looking all files about "chat" and can not find anything like that ... maybe because I'm a little awkward in this or something haha

  2. #16
    Mad Scientist <span style='color: #008000'><span class='glow_006400'>slp13at420</span></span>'s Avatar



    Join Date
    Dec 2013
    Location
    Idaho
    Posts
    2,497
    XP
    20,134,837
    Level
    500
    Thanks
    1,092
    Thanked 333 Times in 213 Posts
    lol me too . its got my interest peaked though lol .
    right now trying it with just a script dunno if I can cover every chat though.
    Achievements:
    Shopper Got a Sticky! Member 1 year registered Level XL Level D
    Awards:
    Pot Head LOL Raffle Winner Top Tagger Donator Hangman Scripter Repacker Drunk Support Member of Staff Da Bomb!
    "Cuz PvP's better with a bag 'o' weed"
    !! King Spade !!

    -Guild Plot System-
    Grumbo'z Guild Warz


    -VIP System-
    Grumbo'z VIP System

  3. #17
    Mad Scientist <span style='color: #008000'><span class='glow_006400'>slp13at420</span></span>'s Avatar



    Join Date
    Dec 2013
    Location
    Idaho
    Posts
    2,497
    XP
    20,134,837
    Level
    500
    Thanks
    1,092
    Thanked 333 Times in 213 Posts
    here is what I have been tinkering with so far ...


    Code:
    
    #include "Chat.h"
    #include "Language.h"
    #include "Player.h"
    #include "ScriptMgr.h"
    #include <unordered_map>
    #include "World.h"
    #include "WorldSession.h"
    
    bool USE_GM_BADGE = true;
    
    std::string CBAC[8][3] = { { "0", "2a", "2b" },  { "1", "says", "|cffFFFFFF"}, { "2", "2a", "2b" }, { "3", "3a", "3b" }, { "4", "[Guild]", "|cff008000" }, { "5", "5a", "5b" }, { "6", "yells", "|cffFF0000" }, { "7", "whispers", "|cffDA70D6" } };
    
    void SendMessage(uint8 type, std::string message, Player* player, Player* chat_target)
    {
    	float SAY_DISTANCE = sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_SAY);
    	float YELL_DISTANCE = sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_YELL);
    	Position pos = player->GetPosition();
    	auto SENDER_TEAM_ID = player->GetTeamId();
    	uint32 GUILD_ID = player->GetGuildId();
    
    	SessionMap sessions = sWorld->GetAllSessions();
    
    		for (SessionMap::iterator itr = sessions.begin(); itr != sessions.end(); ++itr)
    		{
    
    			if (!itr->second)
    				continue;
    
    			Player *target = itr->second->GetPlayer();
    
    			if (type == 1) // say
    			{
    				if (target->GetDistance(pos) <= SAY_DISTANCE)
    					ChatHandler(target->GetSession()).PSendSysMessage(message.c_str());
    			}
    	
    			if ((type == 4)&&(target->GetGuildId() > 0)&&(target->GetGuildId() == GUILD_ID)) // guild
    			{
    				ChatHandler(target->GetSession()).PSendSysMessage(message.c_str());
    			}
    
    			if (type == 6) // yell
    			{
    				if (target->GetDistance(pos) <= YELL_DISTANCE)
    					ChatHandler(target->GetSession()).PSendSysMessage(message.c_str());
    			}
    
    			if (type == 7) // whisper
    			{
    				if (target->GetName() == chat_target->GetName())
    					ChatHandler(target->GetSession()).PSendSysMessage(message.c_str());
    
    			}
    		}
    }
    
    std::string EditMessage(uint8 type, std::string name, std::string message, bool gm)
    {
    	TC_LOG_INFO("server.loading", "TYPE:%u", type);
    
    		if (CBAC[type])
    		{
    			TC_LOG_INFO("server.loading", "NAME:%s", CBAC[type][1]);
    			TC_LOG_INFO("server.loading", "COLOR:%s", CBAC[type][2]);
    
    			// tags
    			std::string TAG = "<Tag>|r";
    			std::string GM_ICON = "|TINTERFACE/CHATFRAME/UI-CHATICON-BLIZZ:13:13:0:-1|t";
    			std::string NAME = "[|Hplayer:" + name + "|h" + name + "]";
    
    			// 1 say :: 6 yell :: 7 whisper ::
    			message = CBAC[type][2] + ":" + message + "|r";
    
    			if (type != 4) { message = CBAC[type][2] + CBAC[type][1] + "|r" + message; };
    
    			message = CBAC[type][2] + NAME + "|r" + message;
    			message = CBAC[type][2] +  TAG + "|r" + message;
    
    				if (type == 4)
    				{
    					message = CBAC[type][2] + CBAC[type][1] + "|r" + message;
    				}
    
    				if ((gm)&&(USE_GM_BADGE))
    				{
    					message = GM_ICON + message;
    				}
    
    		}
    	return message;
    }
    
    class Player_Chat_For_Tagger : public PlayerScript
    {
    public: Player_Chat_For_Tagger() : PlayerScript("Player_Chat_For_Tagger") { }
    
    		virtual void OnChat(Player* player, uint32 type, uint32 lang, std::string& msg) // say
    		{
    			if ((lang != LANG_ADDON) && (msg != "" || "Away") && (player->CanSpeak() == true))
    			{
    				std::string message = EditMessage(type, player->GetName(), msg, player->IsGameMaster());
    				SendMessage(type, message, player, NULL);
    
    				msg = -1;
    			}
    		}
    
    		virtual void OnChat(Player* player, uint32 type, uint32 lang, std::string& msg, Player* receiver) // whisper
    		{
    			if ((lang != LANG_ADDON) && (msg != "" || "Away") && (player->CanSpeak() == true))
    			{
    				std::string message = EditMessage(type, player->GetName(), msg, player->IsGameMaster());
    				SendMessage(type, message, player, receiver);
    
    				msg = -1;
    			}
    		}
    
    
    		virtual void OnChat(Player* player, uint32 type, uint32 lang, std::string& msg, Group* group) // group
    		{
    			if ((lang != LANG_ADDON) && (msg != "" || "Away") && (player->CanSpeak() == true))
    			{
    				std::string message = EditMessage(type, player->GetName(), msg, player->IsGameMaster());
    				SendMessage(type, message, player, NULL);
    
    //				msg = -1;
    			}
    		}
    		
    		virtual void OnChat(Player* player, uint32 type, uint32 lang, std::string& msg, Guild* guild)
    		{
    			if ((lang != LANG_ADDON) && (msg != "" || "Away") && (player->CanSpeak() == true))
    			{
    				std::string message = EditMessage(type, player->GetName(), msg, player->IsGameMaster());
    
    				SendMessage(type, message, player, NULL);
    
    				msg = -1;
    			}
    		}
    
    		virtual void OnChat(Player* player, uint32 type, uint32 lang, std::string& msg, Channel* channel) // channel
    		{
    			if ((lang != LANG_ADDON) && (msg != "" || "Away") && (player->CanSpeak() == true))
    			{
    //				std::string message = EditMessage(type, player->GetName(), msg, player->IsGameMaster());
    
    //				SendMessage(type, message, player, NULL);
    
    //				msg = -1;
    			}
    		}
    
    };
    
    void AddSC_ChatBadgeAdder()
    {
    	new Player_Chat_For_Tagger;
    }
    
    Last edited by slp13at420; 07-25-2016 at 04:05 AM.
    Achievements:
    Shopper Got a Sticky! Member 1 year registered Level XL Level D
    Awards:
    Pot Head LOL Raffle Winner Top Tagger Donator Hangman Scripter Repacker Drunk Support Member of Staff Da Bomb!
    "Cuz PvP's better with a bag 'o' weed"
    !! King Spade !!

    -Guild Plot System-
    Grumbo'z Guild Warz


    -VIP System-
    Grumbo'z VIP System

  4. #18
    Mad Scientist <span style='color: #008000'><span class='glow_006400'>slp13at420</span></span>'s Avatar



    Join Date
    Dec 2013
    Location
    Idaho
    Posts
    2,497
    XP
    20,134,837
    Level
    500
    Thanks
    1,092
    Thanked 333 Times in 213 Posts
    came across an error when dealing with a chat type that isn't in the table yet ..took some time to get itt to check for nil data but now it does:

    Code:
    
    #include "Channel.h"
    // #include "ChannelMgr.h"
    #include "Chat.h"
    #include "Language.h"
    // #include "ObjectMgr.h"
    #include "Player.h"
    // #include "RBAC.h"
    #include "ScriptMgr.h"
    #include <unordered_map>
    #include "World.h"
    #include "WorldSession.h"
    
    bool USE_GM_BADGE = true;
    std::string CBAC[8][3] = { { "0", "0a", "0b" },  { "1", "says", "|cffFFFFFF"}, { "2", "2a", "2b" }, { "3", "3a", "3b" }, { "4", "[Guild]", "|cff008000" }, { "5", "5a", "5b" }, { "6", "yells", "|cffFF0000" }, { "7", "whispers", "|cffDA70D6" } };
    
    void SendMessage(uint8 type, std::string message, Player* player, Player* chat_target)
    {
    float SAY_DISTANCE = sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_SAY);
    float YELL_DISTANCE = sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_YELL);
    
    Position pos = player->GetPosition();
    auto SENDER_TEAM_ID = player->GetTeamId();
    uint32 GUILD_ID = player->GetGuildId();
    
    SessionMap sessions = sWorld->GetAllSessions();
    
    	for (SessionMap::iterator itr = sessions.begin(); itr != sessions.end(); ++itr)
    	{
    
    		if (!itr->second)
    			continue;
    
    		Player *target = itr->second->GetPlayer();
    
    		if ((type == 1)&&(target->GetDistance(pos) <= SAY_DISTANCE))// say
    		{
    			ChatHandler(target->GetSession()).PSendSysMessage(message.c_str());
    		}
    	
    		if ((type == 4)&&(target->GetGuildId() > 0)&&(target->GetGuildId() == GUILD_ID))// guild
    		{
    			ChatHandler(target->GetSession()).PSendSysMessage(message.c_str());
    		}
    
    		if ((type == 6)&&(target->GetDistance(pos) <= YELL_DISTANCE)) // yell
    		{
    			ChatHandler(target->GetSession()).PSendSysMessage(message.c_str());
    		}
    
    		if ((type == 7)&&(target->GetName() == chat_target->GetName())) // whisper
    		{
    			ChatHandler(target->GetSession()).PSendSysMessage(message.c_str());
    		}
    	}
    }
    
    std::string EditMessage(uint8 type, std::string name, std::string message, bool gm)
    {
    //	TC_LOG_INFO("server.loading", "TYPE:%u", type);
    
    	if ((CBAC[type]) && (CBAC[type][2].size() > 0))
    		{
    //			TC_LOG_INFO("server.loading", "PASSED.");
    //			TC_LOG_INFO("server.loading", "NAME:%s", CBAC[type][1]);
    //			TC_LOG_INFO("server.loading", "COLOR:%s", CBAC[type][2]);
    
    			// tags
    			std::string TAG = "<Tag>|r";
    			std::string GM_ICON = "|TINTERFACE/CHATFRAME/UI-CHATICON-BLIZZ:13:13:0:-1|t";
    			std::string NAME = "[|Hplayer:" + name + "|h" + name + "]";
    
    			// 1 say :: 4 guild :: 6 yell :: 7 whisper ::
    			message = CBAC[type][2] + ":" + message + "|r";
    
    				if (type != 4) { message = CBAC[type][2] + CBAC[type][1] + "|r" + message; };
    
    			message = CBAC[type][2] + NAME + "|r" + message;
    			message = CBAC[type][2] +  TAG + "|r" + message;
    
    				if (type == 4)
    				{
    					message = CBAC[type][2] + CBAC[type][1] + "|r" + message;
    				}
    
    				if ((gm)&&(USE_GM_BADGE))
    				{
    					message = GM_ICON + message;
    				}
    
    		}
    	return message;
    }
    
    class Player_Chat_For_Tagger : public PlayerScript
    {
    public: Player_Chat_For_Tagger() : PlayerScript("Player_Chat_For_Tagger") { }
    
    		virtual void OnChat(Player* player, uint32 type, uint32 lang, std::string& msg) // say
    		{
    			if ((lang != LANG_ADDON) && (msg != "" || "Away") && (player->CanSpeak() == true))
    			{
    				std::string message = EditMessage(type, player->GetName(), msg, player->IsGameMaster());
    				SendMessage(type, message, player, NULL);
    
    				msg = -1;
    			}
    		}
    
    		virtual void OnChat(Player* player, uint32 type, uint32 lang, std::string& msg, Player* receiver) // whisper
    		{
    			if ((lang != LANG_ADDON) && (msg != "" || "Away") && (player->CanSpeak() == true))
    			{
    				std::string message = EditMessage(type, player->GetName(), msg, player->IsGameMaster());
    				SendMessage(type, message, player, receiver);
    
    				msg = -1;
    			}
    		}
    
    
    		virtual void OnChat(Player* player, uint32 type, uint32 lang, std::string& msg, Group* group) // group
    		{
    			if ((lang != LANG_ADDON) && (msg != "" || "Away") && (player->CanSpeak() == true))
    			{
    				std::string message = EditMessage(type, player->GetName(), msg, player->IsGameMaster());
    				SendMessage(type, message, player, NULL);
    
    //				msg = -1;
    			}
    		}
    		
    		virtual void OnChat(Player* player, uint32 type, uint32 lang, std::string& msg, Guild* guild)
    		{
    			if ((lang != LANG_ADDON) && (msg != "" || "Away") && (player->CanSpeak() == true))
    			{
    				std::string message = EditMessage(type, player->GetName(), msg, player->IsGameMaster());
    
    				SendMessage(type, message, player, NULL);
    
    				msg = -1;
    			}
    		}
    
    		virtual void OnChat(Player* player, uint32 type, uint32 lang, std::string& msg, Channel* channel) // channel
    		{
    			if ((lang != LANG_ADDON) && (msg != "" || "Away") && (player->CanSpeak() == true))
    			{
    //				std::string message = EditMessage(type, player->GetName(), msg, player->IsGameMaster());
    
    //				SendMessage(type, message, player, NULL);
    
    //				msg = -1;
    			}
    		}
    
    };
    
    void AddSC_ChatBadgeAdder()
    {
    	new Player_Chat_For_Tagger;
    }
    
    the green for Guild chat needs to be brighter lol

    this does NOT edit the existing chat channels but rather intercepts the message and bypasses the chat system completely then it edits the message with tags then it sends the message to the world to be received by selected players based on the chat type making it appear like it was sent by the chat system.
    so far this does say, yell, guild and whisper.

    tag for names2.jpg
    Last edited by slp13at420; 07-29-2016 at 03:31 AM.
    Achievements:
    Shopper Got a Sticky! Member 1 year registered Level XL Level D
    Awards:
    Pot Head LOL Raffle Winner Top Tagger Donator Hangman Scripter Repacker Drunk Support Member of Staff Da Bomb!
    "Cuz PvP's better with a bag 'o' weed"
    !! King Spade !!

    -Guild Plot System-
    Grumbo'z Guild Warz


    -VIP System-
    Grumbo'z VIP System

  5. #19
    Original Poster
    Member
    Join Date
    Jul 2016
    Posts
    33
    XP
    370
    Level
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    It looks very good, I'm gonna test it.

    Sorry for reply too late, I was doing some extra things.

    In some hours I'm gonna reply again to tell u my report.

    Thanks a lot.

  6. #20
    Mad Scientist <span style='color: #008000'><span class='glow_006400'>slp13at420</span></span>'s Avatar



    Join Date
    Dec 2013
    Location
    Idaho
    Posts
    2,497
    XP
    20,134,837
    Level
    500
    Thanks
    1,092
    Thanked 333 Times in 213 Posts
    the whisper needs a line for whisper to who . I just been trying to update some other projects for latest rev ... lol
    Achievements:
    Shopper Got a Sticky! Member 1 year registered Level XL Level D
    Awards:
    Pot Head LOL Raffle Winner Top Tagger Donator Hangman Scripter Repacker Drunk Support Member of Staff Da Bomb!
    "Cuz PvP's better with a bag 'o' weed"
    !! King Spade !!

    -Guild Plot System-
    Grumbo'z Guild Warz


    -VIP System-
    Grumbo'z VIP System

Thread Information

Users Browsing this Thread

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

Tags for this Thread

Posting Permissions

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