31.03.2016, 14:18
(
Последний раз редактировалось Kar; 12.11.2017 в 19:11.
)
Continuing my discussion thread at http://forum.sa-mp.com/showthread.ph...58#post3679258
FEATURES:
This include searches for IPs in strings.
The function searches for numbers ranging from 0-255 in a string. If it atleast 4 of these, then the string contains an IP.
USAGE:
SYTNAX:
stringContainsIP(const szStr[], bool:fixedSeparation = false, bool:ignoreNegatives = false, bool:ranges = true);FEATURES:
This include searches for IPs in strings.
The function searches for numbers ranging from 0-255 in a string. If it atleast 4 of these, then the string contains an IP.
USAGE:
pawn Код:
public OnPlayerText(playerid, text[])
{
if(stringContainsIP(text)) {
SendClientMessage(playerid, "Text blocked for advertising.");
return 0;
}
return 1;
}
SYTNAX:
- bool:ignoreNegatives:
- By default, it will detect negative numbers as IPs also.
- So, if false "-1.-1.-1.-1" would be an IP. If true, "-1.-1.-1.-1" would not be an IP.
TEST RESULTS:
pawn Код:
[31/03/2016 10:14:05][05/04/2016 17:50:10] 000.000.000.000 - 1.
[05/04/2016 17:50:10] 0.0.0.0 - 1.
[05/04/2016 17:50:10] 127.0.0.1 - 1.
[05/04/2016 17:50:10] 127 . 0. 0. 1: 7777 - 1.
[05/04/2016 17:50:10] 255.255.255.255 - 1.
[05/04/2016 17:50:10] PLS COME JOIN SERVER 37____187____22____119 - 1.
[05/04/2016 17:50:10] PLS COME JOIN SERVER 37 $$$$ 187 $$$$ 22 $$$$ 119 - 1.
[05/04/2016 17:50:10] -32.-187.-22.-119 - NOTE: REMOVE THE -s AND JOIN NOW! - 1.
[05/04/2016 17:50:10] 255-255-255-255:7777 - 1.
[05/04/2016 17:50:10] -1.-1.-1.-1 - 1.
[05/04/2016 17:50:10] 0000.000.000.0000 - 0.
[05/04/2016 17:50:10] 255.256.255.255 - 0.
[05/04/2016 17:50:10] 1-1.1-1.1-1.1-1 - 1.
https://github.com/karimcambridge/samp-anti-advertising
CREDITS:
RyDer` for base function.
DISCLAIMER:
Use regex for better results.