Banning an IP script
#1

Hello, does anyone know why my command to ban an IP doesn't work. My ban command works perfectly, but the player just joins with another name. Can any of you take a quick look at it an tell me what I can add to actually ban the IP an keep it banned until someone unbans it. I would appreciate it alot.. Thanks in advanced

Heres the code:

Код:
CMD:banip(playerid, params[])
{
	if(IsPlayerConnected(playerid)) {
	    new string[128], tmp[32];
		if(sscanf(params, "s[32]", tmp)) return SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: /banip [ip]");
		if(PlayerInfo[playerid][pAdmin] >= 1337) {
			AddBan(tmp);
			format(string, sizeof(string), "AdmCmd: %s has banned IP:%s", GetPlayerNameEx(playerid), tmp);
			ABroadCast(COLOR_RED,string,2);
		} else {
  			SendClientMessage(playerid, COLOR_GRAD2, "   You are not authorized to use that command !");
		}
	}
	return 1;
}
Reply
#2

I think you wanna ban an IP while he's not connected.Something like this:
pawn Код:
format(string,sizeof(string),"banip %s",tmp);
       SendRconCommand(string);
       SendRconCommand("reloadbans");
       GetPlayerName(playerid, sendername, sizeof(sendername));
       format(string, 256, "AdmCmd: %s has banned the IP: %s", sendername,tmp);
       ABroadCast(COLOR_LIGHTRED,string,1);
IsPlayerConnected is not needed.
Reply
#3

Would need to see the AddBan method. I also might add that using IsPlayerConnected in commands is unnecessary.
Reply
#4

AddBan

Код:
AddBan(ip[])
{
	if (CheckBan(ip) == 0)
	{
		new File: file = fopen("ban.cfg", io_append);
		new string[20];
		format(string, sizeof(string), "%s", ip);
	 	fwrite(file, string);
	 	fclose(file);
	 	foreach(Player, playerid)
		{
		    new playerIP[16];
			GetPlayerIp(playerid, playerIP, sizeof(playerIP));
			if (strcmp(playerIP, ip) == 0)
			{
	            SendClientMessage(playerid, COLOR_WHITE, "SERVER: You are banned from this server.");
				SetTimerEx("KickPlayer",500,false,"i",playerid);
			}
		}
		return 1;
	}
	return 0;
}
Oh, thank you
Reply
#5

Bump. Very sorry I just needa get this guy banned fast
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)