Posts: 2,938
Threads: 162
Joined: May 2010
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:
pawn Код:
public OnPlayerText(playerid, text[])
{
if(stringContainsIP(text)) {
SendClientMessage(playerid, "Text blocked for advertising.");
return 0;
}
return 1;
}
SYTNAX:
stringContainsIP(const
szStr[], bool:
fixedSeparation =
false, bool:
ignoreNegatives =
false, bool:
ranges =
true);
- 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.
DOWNLOAD:
https://github.com/karimcambridge/samp-anti-advertising
CREDITS:
RyDer` for base function.
DISCLAIMER:
Use regex for better results.
Posts: 607
Threads: 90
Joined: Feb 2011
Reputation:
0
It's useful, thanks, it'll help!
Posts: 68
Threads: 5
Joined: Jul 2015
What about commas?
Example:
255, 255.255, 255:7777
or:
255,255,255.255;7777
Posts: 2,938
Threads: 162
Joined: May 2010
Quote:
Originally Posted by JokeyL
What about commas?
Example:
255, 255.255, 255:7777
or:
255,255,255.255;7777
|
It detects those.
Posts: 1,308
Threads: 47
Joined: Nov 2013
Reputation:
0
Great, release before today i always used regex.
Posts: 2,938
Threads: 162
Joined: May 2010
Update: Added an option to ignore negative numbers. Commit:
https://github.com/Kar2k/samp-anti-a...6041366c17e54c
Posts: 1,398
Threads: 25
Joined: Jan 2014
Reputation:
0
What about detection of domain name as IP (eg: samp.example.net:7777).
Posts: 68
Threads: 5
Joined: Jul 2015
Код:
255-255-255-255:7777
Don't detect.
Posts: 68
Threads: 5
Joined: Jul 2015
Posts: 96
Threads: 23
Joined: Aug 2012
Reputation:
0
great script, but it has to block dns ips too like server.roleplay.com:7777
Posts: 2,938
Threads: 162
Joined: May 2010
Quote:
Originally Posted by JokeyL
Код:
255-255-255-255:7777
Don't detect.
|
Quote:
Originally Posted by SickAttack
|
Works now.
[05/04/2016 17:12:17] 255-255-255-255:7777 - 1.
Fixed in
https://github.com/Kar2k/samp-anti-a...b690a7b26728a4
Posts: 2,938
Threads: 162
Joined: May 2010
Added an option to check for fixed separation between ip numbers. Enabled by default.
Meaning 127 ....... 0. 1. 1. is not a valid IP but 127.0.1.1 is a valid
IP.
If you have people speaking etc in your server, you should leave this on
by default.
https://github.com/Kar2k/samp-anti-a...50151c64b769e9
Posts: 2,938
Threads: 162
Joined: May 2010
UPDATE!
- Disabled fixed seperation by default.
- Added support for ranges.
- Added support for numbers such as 0255 or 0005 (technically people can use this to advertise E.G (join my server at 0192. 0169 .0094.030.. and tell them to take out the 0s which would then be 192.169.94.30)
pawn Код:
[12/02/2017 23:00:27] 000.000.000.000 - 1.
[12/02/2017 23:00:27] 0000.000.000.0000 - 1.
[12/02/2017 23:00:27] 0052.255.255.0000 - 1.
[12/02/2017 23:00:27] 0.0.0.0 - 1.
[12/02/2017 23:00:27] 127.0.0.1 - 1.
[12/02/2017 23:00:27] 127 . 0. 0. 1: 7777 - 1.
[12/02/2017 23:00:27] 255.255.255.255 - 1.
[12/02/2017 23:00:27] PLS COME JOIN SERVER 37____187____22____119 - 1.
[12/02/2017 23:00:27] PLS COME JOIN SERVER 37 $$$$ 187 $$$$ 22 $$$$ 119 - 1.
[12/02/2017 23:00:27] -32.-187.-22.-119 - NOTE: REMOVE THE -s AND JOIN NOW! - 1.
[12/02/2017 23:00:27] 255-255-255-255:7777 - 1.
[12/02/2017 23:00:27] -1.-1.-1.-1 - 1.
[12/02/2017 23:00:27] *.*.*.* - 1.
[12/02/2017 23:00:27] 255.*.*.* - 1.
[12/02/2017 23:00:27] 255.255.*.* - 1.
[12/02/2017 23:00:27] 255.255.255.* - 1.
[12/02/2017 23:00:27] 1-1.1-1.1-1.1-1 - 1.
[12/02/2017 23:00:27] ana oltlo gam3 al 11.5m ra7 2ly gm3thom b3ad keda oltlo gam3 12m 2ly gm3thom fa olto gam3 12.5 - 1.
[12/02/2017 23:00:27] 255.256.255.255 - 0.
[12/02/2017 23:00:27] 0052.255.255.1231 - 0.
https://github.com/karimcambridge/sa...daf6b0b4d624cd
Posts: 118
Threads: 10
Joined: May 2013
Код:
public OnPlayerText(playerid, text[])
{
if (stringContainsIP(text, false, true))
{
default.pwn(1927) : error 047: array sizes do not match, or destination array is too small
Also links in your Github Repository must be updated.
Posts: 120
Threads: 29
Joined: Jan 2017
Reputation:
0
The include don't work, bro!