Advertisement
Guest User

Custom Chat Censoring

a guest
Jul 4th, 2013
1,090
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.02 KB | None | 0 0
  1. /*
  2.   _____                        ____              
  3.  |  ___| __ ___ _______ _ __  / ___|___  _ __ ___
  4.  | |_ | '__/ _ \_  / _ \ '_ \| |   / _ \| '__/ _ \
  5.  |  _|| | | (_) / /  __/ | | | |__| (_) | | |  __/
  6.  |_|  |_|  \___/___\___|_| |_|\____\___/|_|  \___|
  7.      Lightning speed and strength
  8.          conjured directly from the depths of logic!  
  9.             Infusion-WoW 2011 - 2012 (C)
  10. <--------------------------------------------------------------------------->
  11.  - Developer(s): Styler
  12.  - Complete: 100%
  13.  - ScriptName: 'System_Censure'
  14.  - Comment: N/A
  15. <--------------------------------------------------------------------------->
  16. */
  17. #include "ScriptPCH.h"
  18. #include "Channel.h"
  19.  
  20. class System_Censure : public PlayerScript
  21. {
  22. public:
  23.         System_Censure() : PlayerScript("System_Censure") {}
  24.  
  25.         void OnChat(Player* player, uint32 /*type*/, uint32 lang, std::string& msg)
  26.         {
  27.                 CheckMessage(player, msg, lang, NULL, NULL, NULL, NULL);
  28.         }
  29.  
  30.         void OnChat(Player* player, uint32 /*type*/, uint32 lang, std::string& msg, Player* receiver)
  31.         {
  32.                 CheckMessage(player, msg, lang, receiver, NULL, NULL, NULL);
  33.         }
  34.  
  35.         void OnChat(Player* player, uint32 /*type*/, uint32 lang, std::string& msg, Group* group)
  36.         {
  37.                 CheckMessage(player, msg, lang, NULL, group, NULL, NULL);
  38.         }
  39.  
  40.         void OnChat(Player* player, uint32 /*type*/, uint32 lang, std::string& msg, Guild* guild)
  41.         {
  42.                 CheckMessage(player, msg, lang, NULL, NULL, guild, NULL);
  43.         }
  44.  
  45.         void OnChat(Player* player, uint32 /*type*/, uint32 lang, std::string& msg, Channel* channel)
  46.         {
  47.                 CheckMessage(player, msg, lang, NULL, NULL, NULL, channel);
  48.         }
  49.  
  50. void CheckMessage(Player* player, std::string& msg, uint32 lang, Player* /*receiver*/, Group* /*group*/, Guild* /*guild*/, Channel* channel)
  51. {
  52.     //if (player->isGameMaster() || lang == LANG_ADDON)
  53.             //return;
  54.  
  55.     // transform to lowercase (for simpler checking)
  56.     std::string lower = msg;
  57.     std::transform(lower.begin(), lower.end(), lower.begin(), ::tolower);
  58.  
  59.     uint8 cheksSize = 11;//Change these if you want to add more words to the array.
  60.     std::string checks[11];//Change these if you want to add more words to the array.
  61.     // Strony (Sites)
  62.     checks[0] ="Styler is gay";
  63.     checks[1] ="Styler is Homosexual";
  64.     checks[2] ="Infusion-WoW Sucks";
  65.     checks[3] ="Fuck Styler";
  66.     checks[4] ="I hate Styler";
  67.     checks[5] ="Styler is retarded";
  68.     checks[6] ="Screw Styler";
  69.     checks[7] ="wow-";
  70.     checks[8] ="-wow";
  71.     checks[9] =".pl";
  72.     checks[10] ="lumiawow is better than Deception";
  73.  
  74.     for (int i = 0; i < cheksSize; ++i)
  75.         if (lower.find(checks[i]) != std::string::npos)
  76.         {
  77.             msg = "";
  78.             ChatHandler(player->GetSession()).PSendSysMessage("Advertising and vulgar behavior is not allowed!");
  79.             return;
  80.         }
  81. }
  82. };
  83.  
  84. void AddSC_System_Censure()
  85. {
  86.     new System_Censure();
  87. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement