CHECK DYNAMIC IP FUNCTION?
#1

Hello guys, i want to edit my ban system using "gpci".

NAME: Test, IP: 122.122.122.555, SERIAL: 4084DADD58D44E0DED884D4FE4ECEED5D04CEE84

NAME: Test2, IP: 122.122.122.777, SERIAL: 4084DADD58D44E0DED884D4FE4ECEED5D04CEE84

So i need a function to detect if these two IPs are in the same range but i don't have any ideas right now. In my mind i have something like if( 122.122.122.*** == 122.122.122.*** ) => check if( SERIAL1 == SERIAL2 ) => KICK.

I would try the strfind with the "position" but some IPs have this format: **.***.**.*** or ***.***.**.*** so i can't use this way. (I'm using MySQL)

EDIT: Can i use something like
pawn Код:
SELECT * FROM `Banlist` WHERE `IP` LIKE '%127.0.0.1%'
?
Reply
#2

To compare two things is a function strcmp.

pawn Код:
new Test[16] = "122.122.122.555";
new Test2[16];

for(new i=0; i<1000; i++)
{
format(Test2, 16, "122.122.122.%i", i);
if(strcmp(Test, Test2, true))
{
//IP's are same.
}
else
{
//IP's aren't same.
}
}
Reply
#3

What if his IP will change like this: 122.122.***.*** ?
Reply
#4

pawn Код:
new TestPart1[12] = "122.122.122";
new TestPart2[16] = "122.122.122.555;
new Test2Part1[12], Test2Part2[16];

for(new i=0; i<1000; i++)
{
format(Test2Part1, 12, "
122.122.%i", i);
if(strcmp(TestPart1, Test2Part1, true))
{
//if IP's part1 are same.
for(new u=0; u<1000; u++)
{
format(Test2Part2, 16, "
122.122.%i.%i",i, u);
if(strcmp(TestPart2, Test2Part2, true))
{
//IP's part1+part2 are same - Kick
}
}
}
}
Reply
#5

This check used on OnPLayerConnect... it's not a good ideea.
Reply
#6

Quote:
Originally Posted by nGen.SoNNy
Посмотреть сообщение
What if his IP will change like this: 122.122.***.*** ?
What is it's a player from the same country or multiple? That wouldn't be fair.
Reply
#7

Idk but in my 5 years of activity.. i found "hackers" which can change their ip like that...
Reply
#8

Just rangeban them.
https://sampforum.blast.hk/showthread.php?tid=381712
Reply
#9

Quote:
Originally Posted by BornHuman
Посмотреть сообщение
Rangeban is the absolute worst and ineffective ban method there is.

There is a couple of ways you could extract the range for checking.

sscanf()

pawn Код:
new ip1, ip2;
sscanf(ip, "p<.>ii", ip1, ip2);
format(query, sizeof(query), "SELECT * FROM `Banlist` WHERE `IP` LIKE '%i.%i%%%%'", ip1, ip2);
Reply
#10

Quote:
Originally Posted by Thogy
Посмотреть сообщение
pawn Код:
new TestPart2[16] = "122.122.122.555;
Are you sure you know what you're doing?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)