G2A Many GEOs
SHARE
TWEET

worldchatscript

a guest Apr 7th, 2019 142 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[Player]|cff0000ff[Alliance] ";
  115.                 msg += GetNameLink(player);
  116.                 msg += " |cfffaeb00";
  117.             }
  118.  
  119.             else
  120.             {
  121.                 msg += "|TInterface\\icons\\INV_Bijou_Red:15|t|cFFFFD700[Player]|cffff0000[Horde] ";
  122.                 msg += GetNameLink(player);
  123.                 msg += " |cfffaeb00";
  124.             }
  125.             break;
  126.             // Moderator
  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.            // Vip 1
  143.         case SEC_VIP:
  144.             msg += "|TInterface\\icons\\Mail_GMIcon:15|t|cff000000[VIP]|cffABD473[VIP 1] ";
  145.             msg += GetNameLink(player);
  146.             msg += " |cff51FF59";
  147.             break;
  148.            // Vip 2
  149.         case SEC_VIP2:
  150.             msg += "|TInterface\\icons\\Mail_GMIcon:15|t|cff000000[VIP]|cffABD473[VIP 2] ";
  151.             msg += GetNameLink(player);
  152.             msg += " |cff51FF59";
  153.             break;
  154.            // Vip 3
  155.         case SEC_VIP3:
  156.             msg += "|TInterface\\icons\\Mail_GMIcon:15|t|cff000000[VIP]|cffABD473[VIP 3] ";
  157.             msg += GetNameLink(player);
  158.             msg += " |cff51FF59";
  159.             break;
  160.             // Trial Gm
  161.         case SEC_TRIALGM:
  162.             msg += "|TInterface\\icons\\Mail_GMIcon:15|t|cff000000[Staff]|cffABD473[Trial Gm] ";
  163.             msg += GetNameLink(player);
  164.             msg += " |cff51FF59";
  165.             break;
  166.             // GM
  167.         case SEC_GAMEMASTER:
  168.             msg += "|TInterface\\icons\\Mail_GMIcon:15|t|cff000000[Staff]|cffABD473[GameMaster] ";
  169.             msg += GetNameLink(player);
  170.             msg += " |cff51FF59";
  171.             break;
  172.             // Developer
  173.         case SEC_DEVELOPER:
  174.             msg += "|TInterface\\icons\\Mail_GMIcon:15|t|cff000000[Staff]|cffABD473[Developer] ";
  175.             msg += GetNameLink(player);
  176.             msg += " |cff51FF59";
  177.             break;
  178.             // Admin
  179.         case SEC_ADMINISTRATOR:
  180.             msg += "|TInterface\\icons\\Mail_GMIcon:15|t|cff000000[Staff]|cff9B9B9B[Administrator] ";
  181.             msg += GetNameLink(player);
  182.             msg += " |cff1AFF25";
  183.             break;
  184.             // Owner
  185.         case SEC_OWNER:
  186.             msg += "|TInterface\\icons\\Mail_GMIcon:15|t|cff000000[Staff]|cff9B9B9B[Owner] ";
  187.             msg += GetNameLink(player);
  188.             msg += " |cff1AFF25";
  189.             break;
  190.  
  191.         }
  192.  
  193.         msg += args;
  194.         if (FACTION_SPECIFIC)
  195.         {
  196.             SessionMap sessions = sWorld->GetAllSessions();
  197.             for (SessionMap::iterator itr = sessions.begin(); itr != sessions.end(); ++itr)
  198.                 if (Player* plr = itr->second->GetPlayer())
  199.                     if (plr->GetTeam() == player->GetTeam())
  200.                         sWorld->SendServerMessage(SERVER_MSG_STRING, msg.c_str(), plr);
  201.         }
  202.         else
  203.             sWorld->SendServerMessage(SERVER_MSG_STRING, msg.c_str(), 0);
  204.  
  205.         return true;
  206.  
  207.     }
  208. };
  209.  
  210.  
  211. void AddSC_cs_world_chat()
  212. {
  213.      new cs_world_chat();
  214. }
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