BanIP help.
#1

WHen I ban IP myself and trying to reconnect it still works..
Reply
#2

Show the /ban command.
Reply
#3

Код:
CMD:banip(playerid, params[])
{
	if(!CheckAdmin(playerid, 1)) return NotAuthMSG(playerid);     
	new ip[128],pIP[128],string[128];
	if(sscanf(params,"s[128]",ip)) return SyntaxMSG(playerid, "/banip [IP]");
	format(string, sizeof(string),"banip %s", ip);
	SendRconCommand(string);
	SendRconCommand("reloadbans");
	format(string, sizeof(string), "AdmCmd: %s has just IP banned, %s.", GetName(playerid), ip);
	AMSG(COLOR_LIGHTRED, string);
	foreach(Player, i)
	{
		GetPlayerIp(playerid, pIP, sizeof(pIP));
		if(!strcmp(ip, pIP, true))
		{
			format(string, sizeof(string), "[SERVER]: Your IP %s, has been banned from the server.", pIP);
			KickEx(playerid, string);
		}
	}
	return 1;
}
Reply
#4

pawn Код:
CMD:banip(playerid, params[]) {
    if(!CheckAdmin(playerid, 1)) return NotAuthMSG(playerid);
    new ip[20], pIP[20], str[128];
    if(sscanf(params, "s[20]", ip)) return SyntaxMSG(playerid, "/banip [IP]");
    foreach(Player, i) {
        GetPlayerIp(i, pIP, sizeof(pIP));
        if(!strcmp(ip, pIP, true)) SendClientMessage(i, -1, "[SERVER]: Your IP address has been banned from the server.");
    }
    format(str, sizeof str, "banip %s", pIP);
    SendRconCommand(str);
    SendRconCommand("reloadbans");
    return 1;
}
btw: AFAIK you don't have to kick the player as he will timeout.
btw2: you were using "playerid" in the loop
Reply
#5

Quote:
Originally Posted by Mean
Посмотреть сообщение
pawn Код:
CMD:banip(playerid, params[]) {
    if(!CheckAdmin(playerid, 1)) return NotAuthMSG(playerid);
    new ip[20], pIP[20], str[128];
    if(sscanf(params, "s[20]", ip)) return SyntaxMSG(playerid, "/banip [IP]");
    foreach(Player, i) {
        GetPlayerIp(i, pIP, sizeof(pIP));
        if(!strcmp(ip, pIP, true)) SendClientMessage(i, -1, "[SERVER]: Your IP address has been banned from the server.");
    }
    format(str, sizeof str, "banip %s", pIP);
    SendRconCommand(str);
    SendRconCommand("reloadbans");
    return 1;
}
AFAIK you don't have to kick the player as he will timeout.
Which isn't as "clean" as just kicking the player right then and there.


OT: Is your IP listed in the ban file?
Reply
#6

Replace
pawn Код:
format(string, sizeof(string),"banip %s", ip);
with
pawn Код:
format(string, sizeof(string),"banip %d", ip);
Because: %s is for a word or name and like this, but %d is for a number/integar
Reply
#7

Quote:
Originally Posted by RACGaming
Посмотреть сообщение
Replace
pawn Код:
format(string, sizeof(string),"banip %s", ip);
with
pawn Код:
format(string, sizeof(string),"banip %d", ip);
Because: %s is for a word or name and like this, but %d is for a number/integar
IP is a string.

https://sampwiki.blast.hk/wiki/GetPlayerIp

GetPlayerIp(playerid, name[], len)
Reply
#8

Quote:
Originally Posted by RACGaming
Посмотреть сообщение
Replace
pawn Код:
format(string, sizeof(string),"banip %s", ip);
with
pawn Код:
format(string, sizeof(string),"banip %d", ip);
Because: %s is for a word or name and like this, but %d is for a number/integar
https://sampwiki.blast.hk/wiki/GetPlayerIp

I suggest you read that.
Reply
#9

well, even though my IP is on samp.ban , I can still connect my own server.
going to test with a friend
Reply
#10

You cant ban 127.0.0.1 in 0.3x
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)