Advertisement
Rochet2

Untitled

Mar 8th, 2015
371
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.47 KB | None | 0 0
  1. //Some errors fixed by CyBeR-PrO
  2.  
  3. #include "ScriptPCH.h"
  4. #include "Language.h"
  5. #include "Player.h"
  6. #include "Chat.h"
  7. #include "World.h"
  8. #include "Channel.h"
  9.  
  10. static const char* checks[] = {
  11.     "sytes",
  12.     "instant",
  13.     "dyndns",
  14.     "no-ip",
  15.     "http:",
  16.     ".com",
  17.     ".net",
  18.     ".org",
  19.     ".eu",
  20.     ".fr",
  21.     ".bg",
  22.     ".info",
  23.     ".br",
  24.     "https:",
  25.     "wow",
  26.     "www.",
  27.     "no-ip",
  28.     ".zapto",
  29.     ".biz",
  30.     ".servegame",
  31.  
  32.     "trevonwow",
  33.     "megawow",
  34.     "fatalwow",
  35.     "uniforgiven-wow",
  36.     "wow-autolouco",
  37.     "heaven-wow",
  38.     "fireballwow",
  39.     "wowbrasilpa",
  40.     "fatalitywow",
  41.     "demonic-wow",
  42.     "revenge-wow",
  43.     "heavenwow",
  44.     "undead-wow",
  45.     "linebr",
  46.     "azralon",
  47.     "black-wow",
  48. };
  49. static const size_t checksize = sizeof(checks) / sizeof(*checks);
  50.    
  51.  
  52. static void CheckMessage(Player* player, std::string& msg, uint32 lang)
  53. {
  54.     //if (player->isGameMaster() || lang == LANG_ADDON)
  55.     //    return;
  56.  
  57.     // remove all space characters and transform to lowercase for simpler checking
  58.     std::string checkmsg = msg;
  59.     checkmsg.erase(remove_if(checkmsg.begin(), checkmsg.end(), isspace), checkmsg.end());
  60.     std::transform(checkmsg.begin(), checkmsg.end(), checkmsg.begin(), ::tolower);
  61.  
  62.     for (size_t i = 0; i < checksize; ++i)
  63.     {
  64.         if (checkmsg.find(checks[i]) != std::string::npos)
  65.         {
  66.             msg = "";
  67.             ChatHandler(player->GetSession()).PSendSysMessage("Links/Advertisements are not allowed!");
  68.             return;
  69.         }
  70.     }
  71. };
  72.  
  73. static void OnChat(Player* player, uint32 /*type*/, uint32 lang, std::string& msg)
  74. {
  75.     CheckMessage(player, msg, lang);
  76. }
  77.  
  78. static void OnChat(Player* player, uint32 /*type*/, uint32 lang, std::string& msg, Player* /*receiver*/)
  79. {
  80.     CheckMessage(player, msg, lang);
  81. }
  82.  
  83. static void OnChat(Player* player, uint32 /*type*/, uint32 lang, std::string& msg, Group* /*group*/)
  84. {
  85.     CheckMessage(player, msg, lang);
  86. }
  87.  
  88. static void OnChat(Player* player, uint32 /*type*/, uint32 lang, std::string& msg, Guild* /*guild*/)
  89. {
  90.     CheckMessage(player, msg, lang);
  91. }
  92.  
  93. static void OnChat(Player* player, uint32 /*type*/, uint32 lang, std::string& msg, Channel* /*channel*/)
  94. {
  95.     CheckMessage(player, msg, lang);
  96. }
  97.  
  98. void AddSC_System_Censure()
  99. {
  100.     Script *newscript;
  101.     newscript = new Script;
  102.     newscript->Name = "scripted_on_events";
  103.     newscript->pOnChat = &OnChat;
  104.     newscript->RegisterSelf();
  105. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement