Credits : slp13at420


Just a simple operated world chat script. that includes :
faction icon,
faction colored name,
class icon,
if GM then adds GM Badge, and GM rank.

Just add to your core and compile


WorldChat.cpp
Code:

/*
a simple chat system with an adjustable prefix. default`.chat`.
with adjustable color layout and adjustable channel name.
made by slp13at420 of EmuDevs.com
*/

#include "chat.h"
#include "common.h"
#include "player.h"
#include "RBAC.h"
#include "ScriptPCH.h"
#include <unordered_map>
#include "WorldSession.h"

std::string wc1_world_chat_command = "chat";
std::string wc1_channel_name = "World";

std::string wc1_TeamIcon[2] = {    
    "|TInterface\\icons\\Inv_Misc_Tournaments_banner_Human.png:13|t",
    "|TInterface\\icons\\Inv_Misc_Tournaments_banner_Orc.png:13|t"
};

std::string wc1_GM_ICON = "|TINTERFACE/CHATFRAME/UI-CHATICON-BLIZZ:13:13:0:-1|t";

std::string wc1_GM_RANK[4] = {
    "Player",
    "GM1",
    "GM2",
    "GM3",
};

std::string wc1_ClassIcon[11] = {
    "|TInterface\\icons\\INV_Sword_27.png:13|t",
    "|TInterface\\icons\\INV_Hammer_01.png:13|t",
    "|TInterface\\icons\\INV_Weapon_Bow_07.png:13|t",
    "|TInterface\\icons\\INV_ThrowingKnife_04.png:13|t",
    "|TInterface\\icons\\INV_Staff_30.png:13|t",
    "|TInterface\\icons\\Spell_Deathknight_ClassIcon.png:13|t",
    "|TInterface\\icons\\inv_jewelry_talisman_04.png:13|t",
    "|TInterface\\icons\\INV_Staff_30.png:13|t",
    "|TInterface\\icons\\INV_Staff_30.png:13|t",
    "",
    "|TInterface\\icons\\Ability_Druid_Maul.png:13|t",
};

// color definitions since i hate yellow..
std::string wc1_allyblue = "|cff3399FF";
std::string wc1_hordered = "|cffCC0000";
std::string wc1_white = "|cffFFFFFF";
std::string wc1_green = "|cff00cc00";
std::string wc1_red = "|cffFF0000";
std::string wc1_blue = "|cff6666FF";
std::string wc1_black = "|cff000000";
std::string wc1_grey = "|cff808080";

// apply color to name based on team id.
std::string wc1_TeamColor[2] = { wc1_allyblue, wc1_hordered };

class Player_WorldChat : public PlayerScript
{
public:
    Player_WorldChat() : PlayerScript("Player_WorldChat") { }

    virtual void OnLogin(Player* player, bool /*firstLogin*/)
    {
        ChatHandler(player->GetSession()).PSendSysMessage("type `.%s` for World Chat commands.", wc1_world_chat_command.c_str());
    };
};

class WORLD_CHAT : public CommandScript

{
public:
    WORLD_CHAT() : CommandScript("WORLD_CHAT") { }

    ChatCommand* GetCommands() const
    {
        static ChatCommand commandTable[] =
        {
            { wc1_world_chat_command.c_str(), 1, false, &HandleWorldChatCommand, "World Chat prefix.", NULL },
        };
        return commandTable;
    }

    static bool HandleWorldChatCommand(ChatHandler* handler, const char* msg)
    {
        // here you can apply different colors
        std::string wc1_channelcolor = wc1_grey;
        std::string wc1_gm_rankcolor = wc1_blue;
        std::string wc1_msgcolor = wc1_green;

        Player* player = handler->GetSession()->GetPlayer();
        uint32 guid = player->GetGUIDLow();
        uint32 team_id = player->GetTeamId();
        uint8 class_id = player->getClass() - 1;
        auto gm_rank = player->GetSession()->GetSecurity();

        std::string pName = player->GetName();
        std::string WCMSG = "";

        WCMSG = "[" + wc1_channelcolor + wc1_channel_name + "|r]";
        WCMSG = WCMSG + "[" + wc1_TeamIcon[team_id] + "]";

        if (player->IsGameMaster())
        {
            WCMSG = WCMSG + "[" + wc1_GM_ICON + "]";
            WCMSG = WCMSG + "[" + wc1_gm_rankcolor + wc1_GM_RANK[gm_rank] + "|r]";
        }

        WCMSG = WCMSG + "[" + wc1_ClassIcon[class_id] + "]";
        WCMSG = WCMSG + "[" + wc1_TeamColor[team_id] + pName + "|r]";
        WCMSG = WCMSG + ":" + wc1_msgcolor + msg;

        sWorld->SendGlobalText(WCMSG.c_str(), NULL);
//        msg.erase(); // HeHehehe

        return true;
    };
};

void AddSC_WorldChat()
{
    new Player_WorldChat;
    new WORLD_CHAT;
};
Horde player:


Alliance active GM:









› See More: World Chat script