ulfricmalcom

textfilterr

Oct 21st, 2012
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 2.38 KB | None | 0 0
  1. #define FILTERSCRIPT
  2.  
  3. #include <a_samp>
  4.  
  5. new word[6][20] = {"fuck", "shit", "bitch", "asshole", "fag", "faggot"};
  6. public OnFilterScriptInit()
  7. {
  8.     print("\n--------------------------------------");
  9.     print(" word filter ");
  10.     print("--------------------------------------\n");
  11.     return 1;
  12. }
  13.  
  14. public OnFilterScriptExit()
  15. {
  16.     return 1;
  17. }
  18.  
  19.  
  20. public OnPlayerText(playerid, text[])
  21. {
  22.     SendPlayerMessageToAll(playerid, WordFilter(text));
  23.     return 0;
  24. }
  25. stock WordFilter(const string[]){
  26.     new newString[256];
  27.     new bool:find[6] = {false, ...};
  28.     format(newString, sizeof(newString), "%s", string);
  29.     while(!find[0] || !find[1] || !find[2] || !find[3] || !find[4] || !find[5]){
  30.         if(strfind(newString, word[0], true) == -1){
  31.             find[0] = true;
  32.         }else{
  33.             //idx = strfind(newString, word[0], true);
  34.             format(newString, sizeof(newString), "%s", replace(newString, word[0], "#$%!"));
  35.         }
  36.         if(strfind(newString, word[1], true) == -1){
  37.             find[1] = true;
  38.         }else{
  39.             //idx = strfind(newString, word[1], true, idx);
  40.             format(newString, sizeof(newString), "%s", replace(newString, word[1], "%@!$"));
  41.         }
  42.         if(strfind(newString, word[2], true) == -1){
  43.             find[2] = true;
  44.         }else{
  45.             //idx = strfind(newString, word[2], true, idx);
  46.             format(newString, sizeof(newString), "%s", replace(newString, word[2], "!&@#$"));
  47.         }
  48.         if(strfind(newString, word[3], true) == -1){
  49.             find[3] = true;
  50.         }else{
  51.             //idx = strfind(newString, word[3], true, idx);
  52.             format(newString, sizeof(newString), "%s", replace(newString, word[3], "!@#$%&"));
  53.         }
  54.         if(strfind(newString, word[4], true) == -1){
  55.             find[4] = true;
  56.         }else{
  57.             //idx = strfind(newString, word[4], true, idx);
  58.             format(newString, sizeof(newString), "%s", replace(newString, word[4], "&#@"));
  59.         }
  60.         if(strfind(newString, word[5], true) == -1){
  61.             find[5] = true;
  62.         }else{
  63.             //idx = strfind(newString, word[5], true, idx);
  64.             format(newString, sizeof(newString), "%s", replace(newString, word[5], "&%$#@!"));
  65.         }
  66.     }
  67.     return newString;
  68. }
  69.  
  70. stock replace(const string[], const target[], const replace[]){
  71.     new useString[256];
  72.     format(useString, sizeof(useString), "%s", string);
  73.     if(strfind(string, target) != -1){
  74.  
  75.         new pos = strfind(useString, target);
  76.         strdel(useString , pos, (strlen(target) + pos));
  77.         strins(useString , replace, pos);
  78.     }
  79.     return useString;
  80. }
Advertisement
Add Comment
Please, Sign In to add comment