custom banlist -
Ribber - 26.12.2010
I like to create my own banlist.
the bans will save in a .txt file, it's better than the samp.ban because for every ban i must also reload it with /reloadbans what is dumb since the remote console isn't in the client anymore..
My question now: How can I do that it also kicks him when his ip is range banned?
In file (or for test in the script): 127.0.*.*
player ip: 127.0.0.1
(as example)
my code (in OnPlayerConnect) works with the code below, it searches for the same ip I have:
pawn Код:
if(!strcmp(IP[0],"127",false) && !strcmp(IP[1],"0",false) && !strcmp(IP[2],"0",false) && !strcmp(IP[3],"1",false))
{
new string[128];
format(string,sizeof(string),"Your IP: %s is range banned!",str);
SendClientMessage(playerid,_COLOR_RED,string);
Kick(playerid)
}
but with that, it doesn't work anymore (range ban):
pawn Код:
if(!strcmp(IP[0],"127",false) && !strcmp(IP[1],"0",false) && !strcmp(IP[2],"*",false) && !strcmp(IP[3],"*",false))
{
new string[128];
format(string,sizeof(string),"Your IP: %s is range banned!",str);
SendClientMessage(playerid,_COLOR_RED,string);
Kick(playerid)
}
please help.
Re: custom banlist -
WillyP - 26.12.2010
What doesn't work?
AW: custom banlist -
Ribber - 26.12.2010
forgot to add the whole code, so with the code below it works (because it search for 127.0.0.1 and my ip is also 127.0.0.1:
pawn Код:
public OnPlayerConnect(playerid)
{
new idx;
new IP[4][256];
new str[128];
GetPlayerIp(playerid,str,sizeof(str));
IP[0] = strtok(str, idx, '.');
IP[1] = strtok(str, idx, '.');
IP[2] = strtok(str, idx, '.');
IP[3] = strtok(str, idx, '.');
if(!strcmp(IP[0],"127",false) && !strcmp(IP[1],"0",false) && !strcmp(IP[2],"0",false) && !strcmp(IP[3],"1",false))
{
new string[128];
format(string,sizeof(string),"Your IP: %s is range banned!",str);
SendClientMessage(playerid,_COLOR_RED,string);
Kick(playerid);
}
return 1;
...
}
but when I change that it searchs for 127.0.*.* while my ip is 127.0.0.1, it doesn't work:
pawn Код:
public OnPlayerConnect(playerid)
{
new idx;
new IP[4][256];
new str[128];
GetPlayerIp(playerid,str,sizeof(str));
IP[0] = strtok(str, idx, '.');
IP[1] = strtok(str, idx, '.');
IP[2] = strtok(str, idx, '.');
IP[3] = strtok(str, idx, '.');
if(!strcmp(IP[0],"127",false) && !strcmp(IP[1],"0",false) && !strcmp(IP[2],"*",false) && !strcmp(IP[3],"*",false))
{
new string[128];
format(string,sizeof(string),"Your IP: %s is range banned!",str);
SendClientMessage(playerid,_COLOR_RED,string);
Kick(playerid);
}
return 1;
...
}
Re: custom banlist -
WillyP - 26.12.2010
Maybe keep the '*' '*' blank?
Something like this:
pawn Код:
public OnPlayerConnect(playerid)
{
new idx;
new IP[2][128];
new str[98];
GetPlayerIp(playerid,str,sizeof(str));
IP[0] = strtok(str, idx, '.');
IP[1] = strtok(str, idx, '.');
if(!strcmp(IP[0],"127",false) && !strcmp(IP[1],"0",false))
{
new string[128];
format(string,sizeof(string),"Your IP: %s is range banned!",str);
SendClientMessage(playerid,_COLOR_RED,string);
Kick(playerid);
}
return 1;
...
}
AW: custom banlist -
Ribber - 26.12.2010
yes now it works lol

But I think it will bug when I have the .txt file or?
so at the moment it only searchs for range banned IPs (because i removed the last second ranges), so when in the txt file is the 86.64.15.25 ip banned (for example) it only search the 86.64 and then it thinks it's a range ban.
hope you understood me.
Re: custom banlist -
WillyP - 26.12.2010
Yeah, change the numbers around to the last two.
AW: custom banlist -
Ribber - 26.12.2010
ok I got another question now, how can i do that when a player has an ip (example the 86.64.15.25 again), and in the file is posted "86.64.*.*" that it automatic kicks him because its a range ban?
i dont have an idea :S
Re: custom banlist -
WillyP - 26.12.2010
Maybe this: *.*.15.25
AW: Re: custom banlist -
Ribber - 26.12.2010
and what i must change in the script?
Re: custom banlist -
WillyP - 26.12.2010
pawn Код:
public OnPlayerConnect(playerid)
{
new idx;
new IP[2][128];
new str[50];
GetPlayerIp(playerid,str,sizeof(str));
IP[2] = strtok(str, idx, '.');
IP[3] = strtok(str, idx, '.');
if(!strcmp(IP[2],"15",false) && !strcmp(IP[3],"25",false))
{
new string[128];
format(string,sizeof(string),"Your IP: %s is range banned!",str);
SendClientMessage(playerid,_COLOR_RED,string);
Kick(playerid);
}
return 1;
...
}
Like this.