Advertisement
Romanius

AntiReklama with RegEx

Apr 14th, 2011
1,129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 0.86 KB | None | 0 0
  1. #include <a_samp>
  2. #include <regex>
  3.  
  4. #define REPLACE_TEXT "{FF0000}[РЕЛАМА ЗАПРЕЩЕННА]{FFFFFF}"
  5.  
  6. new RegEx:anti_reklama;
  7.  
  8. public OnFilterScriptInit()
  9. {
  10.     anti_reklama = regex_build("(((file|gopher|news|nntp|telnet|http|ftp|https|ftps|sftp|samp)://)|(www\\.|\\,|))+(([a-zA-Z0-9\\.\\,_-]+(\\.|\\,)[a-zA-Z]{2,6})|([0-9]{1,3}(\\.|\\,)[0-9]{1,3}(\\.|\\,)[0-9]{1,3}(\\.|\\,)[0-9]{1,3}))(/[a-zA-Z0-9\\&amp;%_\\./-~-]*)?");
  11.  
  12.     printf("Антиреклама by Romanius загруженна!");
  13.    
  14.     return 1;
  15. }
  16.  
  17. public OnFilterScriptExit()
  18. {
  19.     regex_delete(anti_reklama);
  20.    
  21.     printf("Антиреклама by Romanius выгруженна!");
  22.    
  23.     return 1;
  24. }
  25.  
  26. public OnPlayerText(playerid, text[])
  27. {
  28.     new message[256];
  29.    
  30.     regex_replace_exid(text, anti_reklama, REPLACE_TEXT, message);
  31.    
  32.     SendPlayerMessageToAll(playerid, message);
  33.    
  34.     return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement