Advertisement
SickAttack

Anti Advertisement System - Simple, yet effective!

Mar 23rd, 2015
2,250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 1.15 KB | None | 0 0
  1. // ** INCLUDES
  2.  
  3. #include <a_samp>
  4. #include <regex>
  5.  
  6. // ** DEFINES
  7.  
  8. // *** FUNCTIONS
  9.  
  10. #define strcpy(%0,%1,%2) strcat((%0[0] = '\0', %0), %1, %2)
  11.  
  12. // ** CALLBACKS
  13.  
  14. public OnFilterScriptInit()
  15. {  
  16.     return 1;
  17. }
  18.  
  19. public OnFilterScriptExit()
  20. {
  21.     return 1;
  22. }
  23.  
  24. public OnPlayerText(playerid, text[])
  25. {
  26.     if(IsAdvertisement(text))
  27.     {
  28.         SendClientMessage(playerid, 0xFF0000FF, "Your message is considered as an advert, please review it.");
  29.         return 0;
  30.     }
  31.     return 1;
  32. }
  33.  
  34. // ** FUNCTIONS
  35.  
  36. forward bool:IsAdvertisement(text[]);
  37. public bool:IsAdvertisement(text[])
  38. {
  39.     new message[128], build, expression[] = "(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.+){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)", start, end;
  40.     strcpy(message, text, sizeof(message));
  41.  
  42.     for(new i = 0, j = strlen(message); i < j; i ++)
  43.     {
  44.         switch(message[i])
  45.         {
  46.             case '0'..'9': continue;
  47.             case '.': continue;
  48.             default:
  49.             {
  50.                 strdel(message, i, i + 1);
  51.                 strins(message, ".", i);
  52.             }
  53.         }
  54.     }
  55.  
  56.     build = regex_exbuild(expression);
  57.     regex_exmatch(message, build);
  58.     regex_exsearch(message, build, start, end);
  59.  
  60.     if(start >= 0) return true;
  61.     return false;
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement