Advertisement
julienanid

[Classes World Chat] Updated with Icons !

Sep 16th, 2013
256
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.86 KB | None | 0 0
  1. #include "ScriptPCH.h"
  2. #include "Chat.h"
  3. const char* CLASS_ICON;
  4.  
  5. #define FACTION_SPECIFIC 0
  6.  
  7. std::string GetNameLink(Player* player)
  8. {
  9. std::string name = player->GetName();
  10. std::string color;
  11. switch(player->getClass())
  12. {
  13. case CLASS_DEATH_KNIGHT:
  14. color = "|cffC41F3B";
  15. CLASS_ICON = "|TInterface\\icons\\Spell_Deathknight_ClassIcon:15|t|r";
  16. break;
  17. case CLASS_DRUID:
  18. color = "|cffFF7D0A";
  19. CLASS_ICON = "|TInterface\\icons\\Ability_Druid_Maul:15|t|r";
  20. break;
  21. case CLASS_HUNTER:
  22. color = "|cffABD473";
  23. CLASS_ICON = "|TInterface\\icons\\INV_Weapon_Bow_07:15|t|r";
  24. break;
  25. case CLASS_MAGE:
  26. color = "|cff69CCF0";
  27. CLASS_ICON = "|TInterface\\icons\\INV_Staff_13:15|t|r";
  28. break;
  29. case CLASS_PALADIN:
  30. color = "|cffF58CBA";
  31. CLASS_ICON = "|TInterface\\icons\\INV_Hammer_01:15|t|r";
  32. break;
  33. case CLASS_PRIEST:
  34. color = "|cffFFFFFF";
  35. CLASS_ICON = "|TInterface\\icons\\INV_Staff_30:15|t|r";
  36. break;
  37. case CLASS_ROGUE:
  38. color = "|cffFFF569";
  39. CLASS_ICON = "|TInterface\\icons\\INV_ThrowingKnife_04:15|t|r";
  40. break;
  41. case CLASS_SHAMAN:
  42. color = "|cff0070DE";
  43. CLASS_ICON = "|TInterface\\icons\\Spell_Nature_BloodLust:15|t|r";
  44. break;
  45. case CLASS_WARLOCK:
  46. color = "|cff9482C9";
  47. CLASS_ICON = "|TInterface\\icons\\Spell_Nature_FaerieFire:15|t|r";
  48. break;
  49. case CLASS_WARRIOR:
  50. color = "|cffC79C6E";
  51. CLASS_ICON = "|TInterface\\icons\\INV_Weapon_Bow_07:15|t|r";
  52. break;
  53. }
  54. return "|Hplayer:"+name+"|h"+CLASS_ICON+"|cffFFFFFF["+color+name+"|cffFFFFFF]|h|r
  55. }
  56.  
  57. class cs_world_chat : public CommandScript
  58. {
  59. public:
  60. cs_world_chat() : CommandScript("cs_world_chat"){}
  61.  
  62. ChatCommand * GetCommands() const
  63. {
  64. static ChatCommand WorldChatCommandTable[] =
  65. {
  66. {"chat", SEC_PLAYER, true, &HandleWorldChatCommand, "", NULL},
  67. {"c", SEC_PLAYER, true, &HandleWorldChatCommand, "", NULL},
  68. {"world", 1, true, &HandleWorldChatCommand, "", NULL},
  69. {"w", SEC_PLAYER, true, &HandleWorldChatCommand, "", NULL},
  70. {NULL, 0, false, NULL, "", NULL}
  71. };
  72.  
  73. return WorldChatCommandTable;
  74. }
  75.  
  76. static bool HandleWorldChatCommand(ChatHandler * handler, const char * args)
  77. {
  78. if (!handler->GetSession()->GetPlayer()->CanSpeak())
  79. return false;
  80. std::string temp = args;
  81.  
  82. if (!args || temp.find_first_not_of(' ') == std::string::npos)
  83. return false;
  84.  
  85. std::string msg = "";
  86. Player * player = handler->GetSession()->GetPlayer();
  87.  
  88. switch(player->GetSession()->GetSecurity())
  89. {
  90. // Player
  91. case SEC_PLAYER:
  92. if (player->GetTeam() == ALLIANCE)
  93. {
  94. msg += "|cff00ff00[World]";
  95. msg += " |cff0000ff|TInterface\\icons\\Achievement_PVP_A_A:15|t|r";
  96. msg += GetNameLink(player);
  97. msg += ":|cfffaeb00";
  98. }
  99.  
  100. else
  101. {
  102. msg += "|cff00ff00[World] ";
  103. msg += " |cffff0000|TInterface\\icons\\Achievement_PVP_A_H:15|t|r";
  104. msg += GetNameLink(player);
  105. msg += ":|cfffaeb00";
  106. }
  107. break;
  108. // Moderator/trial
  109. case SEC_MODERATOR:
  110. msg += "|cffff8a00[Mod] ";
  111. msg += GetNameLink(player);
  112. msg += " |cfffaeb00";
  113. break;
  114. // GM
  115. case SEC_GAMEMASTER:
  116. msg += "|cff00ffff[GM] ";
  117. msg += GetNameLink(player);
  118. msg += " |cfffaeb00";
  119. break;
  120. // Admin
  121. case SEC_ADMINISTRATOR:
  122. msg += "|cfffa9900[Admin] ";
  123. msg += GetNameLink(player);
  124. msg += " |cfffaeb00";
  125. break;
  126.  
  127. }
  128.  
  129. msg += args;
  130. if (FACTION_SPECIFIC)
  131. {
  132. SessionMap sessions = sWorld->GetAllSessions();
  133. for (SessionMap::iterator itr = sessions.begin(); itr != sessions.end(); ++itr)
  134. if (Player* plr = itr->second->GetPlayer())
  135. if (plr->GetTeam() == player->GetTeam())
  136. sWorld->SendServerMessage(SERVER_MSG_STRING, msg.c_str(), plr);
  137. }
  138. else
  139. sWorld->SendServerMessage(SERVER_MSG_STRING, msg.c_str(), 0);
  140.  
  141. return true;
  142. }
  143. };
  144.  
  145. void AddSC_cs_world_chat()
  146. {
  147. new cs_world_chat();
  148. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement