Guest User

samp anti swear

a guest
Mar 15th, 2013
298
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. #include <a_samp>
  2.  
  3. #define MAX_LEN 32
  4. #define MAX_ENTRY 120
  5.  
  6. static Swear[MAX_ENTRY][MAX_LEN];
  7.  
  8. public OnFilterScriptInit()
  9. {
  10. if(fexist("swear.txt")) {
  11.  
  12. new File:myFile,
  13. line[MAX_LEN],
  14. index=0;
  15.  
  16. myFile=fopen("swear.txt",filemode:io_read);
  17.  
  18. while(fread(myFile,line,sizeof line) && (index != MAX_ENTRY)) {
  19. if(strlen(line)>MAX_LEN) continue;
  20. StripNewLine(line);
  21. strmid(Swear[index],line,0,strlen(line),sizeof line);
  22. index++;
  23. }
  24. }
  25.  
  26. return 1;
  27. }
  28.  
  29. public OnPlayerText(playerid,text[])
  30. {
  31. for(new i=0; i<MAX_ENTRY; i++) {
  32. if(!Swear[i][0]) continue;
  33. Cenzura(text,Swear[i]);
  34. }
  35.  
  36. return 1;
  37. }
  38.  
  39. stock StripNewLine(str[]) // ysi-misc.own
  40. {
  41. new l = strlen(str);
  42. while (l-- && str[l] <= ' ') str[l] = '\0';
  43. }
  44.  
  45. stock Cenzura(string[],word[],destch='*')
  46. {
  47. new start_index=(-1),
  48. end_index=(-1);
  49.  
  50. start_index=strfind(string,word,true);
  51. if(start_index==(-1)) return false;
  52. end_index=(start_index+strlen(word));
  53.  
  54. for( ; start_index<end_index; start_index++)
  55. string[start_index]=destch;
  56.  
  57. return true;
  58. }
Advertisement
Add Comment
Please, Sign In to add comment