Advertisement
Guest User

Untitled

a guest
Sep 19th, 2019
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.53 KB | None | 0 0
  1. #include <sourcemod>
  2. #include <sdkhooks>
  3.  
  4. #pragma semicolon 1
  5. #pragma newdecls required
  6. #pragma tabsize 0
  7.  
  8. #define KvPath "configs/chatbans.cfg"
  9.  
  10. char g_BannedWords[256][PLATFORM_MAX_PATH];
  11. char configFile[PLATFORM_MAX_PATH];
  12. int wordstotal;
  13.  
  14.  
  15. public void OnPluginStart()
  16. {
  17.  
  18. BuildPath(Path_SM, configFile, sizeof(configFile), KvPath);
  19.  
  20. AddCommandListener(Command_Say, "say");
  21. AddCommandListener(Command_Say, "say_team");
  22.  
  23. AutoExecConfig(true, "chatbans_cvars", "sourcemod");
  24. }
  25.  
  26.  
  27. public void OnMapStart()
  28. {
  29. LoadWords();
  30. }
  31.  
  32. public Action Command_Say(int client, const char[] command, int argc)
  33. {
  34. char sText[192];
  35. GetCmdArgString(sText, sizeof(sText));
  36. StripQuotes(sText);
  37.  
  38. for(int i=0; i < wordstotal; i++)
  39. {
  40. if(!StrEqual("", g_BannedWords[i], false) && (StrContains(sText, g_BannedWords[i], false) != -1 || StrEqual(sText, g_BannedWords[i], false))){
  41. KickClient(client, "bye bye everybody");
  42. return Plugin_Handled;
  43. }
  44. }
  45. return Plugin_Continue;
  46. }
  47.  
  48.  
  49. public void LoadWords()
  50. {
  51. wordstotal = 0;
  52.  
  53. KeyValues kv = new KeyValues("Words");
  54. if (!FileExists(configFile)) {
  55. LogError("The playerbans config file (%s) does not exist", configFile);
  56. }
  57.  
  58. if (!kv.ImportFromFile(configFile) || !kv.GotoFirstSubKey()) {
  59. LogError("The executes spawns file was empty");
  60. delete kv;
  61. return;
  62. }
  63.  
  64. do{
  65. kv.GetSectionName(g_BannedWords[wordstotal], sizeof(g_BannedWords[]));
  66. wordstotal++;
  67. }while(kv.GotoNextKey());
  68.  
  69. kv.Rewind();
  70. delete kv;
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement