G2A Many GEOs
SHARE
TWEET

World chat Script

a guest Nov 24th, 2018 749 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include "ScriptPCH.h"
  2. #include "Chat.h"
  3. #include "RBAC.h"
  4. #include "Player.h"
  5. #include "World.h"
  6. #include "ScriptMgr.h"
  7. #include "WorldSession.h"
  8. #include "Common.h"
  9. #include "ObjectMgr.h"
  10. #include "ScriptPCH.h"
  11. #include "Chat.h"
  12. #include "Common.h"
  13. #include "Channel.h"
  14. #include "SocialMgr.h"
  15.  
  16.  
  17. #define FACTION_SPECIFIC 0
  18.  
  19. std::string GetNameLink(Player* player)
  20. {
  21.         std::string name = player->GetName();
  22.         std::string color;
  23.         switch(player->getClass())
  24.         {
  25.         case CLASS_DEATH_KNIGHT:
  26.                 color = "|cffC41F3B";
  27.                 break;
  28.         case CLASS_DRUID:
  29.                 color = "|cffFF7D0A";
  30.                 break;
  31.         case CLASS_HUNTER:
  32.                 color = "|cffABD473";
  33.                 break;
  34.         case CLASS_MAGE:
  35.                 color = "|cff69CCF0";
  36.                 break;
  37.         case CLASS_PALADIN:
  38.                 color = "|cffF58CBA";
  39.                 break;
  40.         case CLASS_PRIEST:
  41.                 color = "|cffFFFFFF";
  42.                 break;
  43.         case CLASS_ROGUE:
  44.                 color = "|cffFFF569";
  45.                 break;
  46.         case CLASS_SHAMAN:
  47.                 color = "|cff0070DE";
  48.                 break;
  49.         case CLASS_WARLOCK:
  50.                 color = "|cff9482C9";
  51.                 break;
  52.         case CLASS_WARRIOR:
  53.                 color = "|cffC79C6E";
  54.                 break;
  55.         }
  56.         return "|Hplayer:"+name+"|h|cffFFFFFF["+color+name+"|cffFFFFFF]|h|r";
  57. }
  58.  
  59. class cs_world_chat : public CommandScript
  60. {
  61. public:
  62.     cs_world_chat() : CommandScript("cs_world_chat") { }
  63.  
  64.     std::vector<ChatCommand> GetCommands() const override
  65.     {
  66.         static std::vector<ChatCommand> commandTable =
  67.         {
  68.             // .c .ch .cha .chat
  69.             { "c", rbac::RBAC_PERM_COMMAND_CUSTOM_CHAT, false, &HandleGlobalChat, "" },
  70.             { "ch", rbac::RBAC_PERM_COMMAND_CUSTOM_CHAT, false, &HandleGlobalChat, "" },
  71.             { "cha", rbac::RBAC_PERM_COMMAND_CUSTOM_CHAT, false, &HandleGlobalChat, "" },
  72.             { "chat", rbac::RBAC_PERM_COMMAND_CUSTOM_CHAT, false, &HandleGlobalChat, "" },
  73.             // .w .wo .wor .worl .world
  74.             { "w", rbac::RBAC_PERM_COMMAND_CUSTOM_CHAT, false, &HandleGlobalChat, "" },
  75.             { "wo", rbac::RBAC_PERM_COMMAND_CUSTOM_CHAT, false, &HandleGlobalChat, "" },
  76.             { "wor", rbac::RBAC_PERM_COMMAND_CUSTOM_CHAT, false, &HandleGlobalChat, "" },
  77.             { "worl", rbac::RBAC_PERM_COMMAND_CUSTOM_CHAT, false, &HandleGlobalChat, "" },
  78.             { "world", rbac::RBAC_PERM_COMMAND_CUSTOM_CHAT, false, &HandleGlobalChat, "" },
  79.             // .g .gl .glo .glob .globa .global
  80.             { "g", rbac::RBAC_PERM_COMMAND_CUSTOM_CHAT, false, &HandleGlobalChat, "" },
  81.             { "gl", rbac::RBAC_PERM_COMMAND_CUSTOM_CHAT, false, &HandleGlobalChat, "" },
  82.             { "glo", rbac::RBAC_PERM_COMMAND_CUSTOM_CHAT, false, &HandleGlobalChat, "" },
  83.             { "glob", rbac::RBAC_PERM_COMMAND_CUSTOM_CHAT, false, &HandleGlobalChat, "" },
  84.             { "globa", rbac::RBAC_PERM_COMMAND_CUSTOM_CHAT, false, &HandleGlobalChat, "" },
  85.             { "global", rbac::RBAC_PERM_COMMAND_CUSTOM_CHAT, false, &HandleGlobalChat, "" },
  86.         };
  87.  
  88.         return commandTable;
  89.     }
  90.  
  91.     static bool HandleGlobalChat(ChatHandler* handler, const char* args)
  92.     {
  93.         Player * player = handler->GetSession()->GetPlayer();
  94.  
  95.         // Player Muted?
  96.         if (!player->CanSpeak())
  97.             return false;
  98.  
  99.         // Other Check.
  100.         std::string temp = args;
  101.  
  102.         if (!args || temp.find_first_not_of(' ') == std::string::npos)
  103.             return false;
  104.  
  105.         std::string msg = "";
  106.          player = handler->GetSession()->GetPlayer();
  107.  
  108.         switch (player->GetSession()->GetSecurity())
  109.         {
  110.             // Player
  111.         case SEC_PLAYER:
  112.             if (player->GetTeam() == ALLIANCE)
  113.             {
  114.                 msg += "|TInterface\\icons\\INV_Bijou_Blue:15|t|cFFFFD700[World]|cff0000ff[Alliance] ";
  115.                 msg += GetNameLink(player);
  116.                 msg += " |cfffaeb00";
  117.             }
  118.  
  119.             else
  120.             {
  121.                 msg += "|TInterface\\icons\\INV_Bijou_Red:15|t|cFFFFD700[World]|cffff0000[Horde] ";
  122.                 msg += GetNameLink(player);
  123.                 msg += " |cfffaeb00";
  124.             }
  125.             break;
  126.             // V.I.P
  127.         case SEC_MODERATOR:
  128.             if (player->GetTeam() == ALLIANCE)
  129.             {
  130.                 msg += "|TInterface\\icons\\Achievement_PVP_A_A:15|t|cffB70093|Alliance]|cffFFFFFF[V|cff28FF28.I|cffFF2424.P] ";
  131.                 msg += GetNameLink(player);
  132.                 msg += " |cff0000FF";
  133.             }
  134.  
  135.             else
  136.             {
  137.                 msg += "|TInterface\\icons\\Achievement_PVP_H_H:15|t|cffB70093|Horde]|cffFFFFFF[V|cff28FF28.I|cffFF2424.P] ";
  138.                 msg += GetNameLink(player);
  139.                 msg += " |cffFF0000";
  140.             }
  141.             break;
  142.             // GM
  143.         case SEC_GAMEMASTER:
  144.             msg += "|TInterface\\icons\\Mail_GMIcon:15|t|cff000000[Staff]|cffABD473[GameMaster] ";
  145.             msg += GetNameLink(player);
  146.             msg += " |cff51FF59";
  147.             break;
  148.             // Admin
  149.         case SEC_ADMINISTRATOR:
  150.             msg += "|TInterface\\icons\\Mail_GMIcon:15|t|cff000000[Staff]|cff9B9B9B[Administrator] ";
  151.             msg += GetNameLink(player);
  152.             msg += " |cff1AFF25";
  153.             break;
  154.  
  155.         }
  156.  
  157.         msg += args;
  158.         if (FACTION_SPECIFIC)
  159.         {
  160.             SessionMap sessions = sWorld->GetAllSessions();
  161.             for (SessionMap::iterator itr = sessions.begin(); itr != sessions.end(); ++itr)
  162.                 if (Player* plr = itr->second->GetPlayer())
  163.                     if (plr->GetTeam() == player->GetTeam())
  164.                         sWorld->SendServerMessage(SERVER_MSG_STRING, msg.c_str(), plr);
  165.         }
  166.         else
  167.             sWorld->SendServerMessage(SERVER_MSG_STRING, msg.c_str(), 0);
  168.  
  169.         return true;
  170.  
  171.     }
  172. };
  173.  
  174.  
  175. void AddSC_cs_world_chat()
  176. {
  177.      new cs_world_chat();
  178. }
RAW Paste Data
Ledger Nano X - The secure hardware wallet
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top