Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ** INCLUDES
- #include <a_samp>
- #include <regex>
- // ** DEFINES
- // *** FUNCTIONS
- #define strcpy(%0,%1,%2) strcat((%0[0] = '\0', %0), %1, %2)
- // ** CALLBACKS
- public OnFilterScriptInit()
- {
- return 1;
- }
- public OnFilterScriptExit()
- {
- return 1;
- }
- public OnPlayerText(playerid, text[])
- {
- if(IsAdvertisement(text))
- {
- SendClientMessage(playerid, 0xFF0000FF, "Your message is considered as an advert, please review it.");
- return 0;
- }
- return 1;
- }
- // ** FUNCTIONS
- forward bool:IsAdvertisement(text[]);
- public bool:IsAdvertisement(text[])
- {
- 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;
- strcpy(message, text, sizeof(message));
- for(new i = 0, j = strlen(message); i < j; i ++)
- {
- switch(message[i])
- {
- case '0'..'9': continue;
- case '.': continue;
- default:
- {
- strdel(message, i, i + 1);
- strins(message, ".", i);
- }
- }
- }
- build = regex_exbuild(expression);
- regex_exmatch(message, build);
- regex_exsearch(message, build, start, end);
- if(start >= 0) return true;
- return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement