SA-MP Forums Archive
Banning an IP script - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Banning an IP script (/showthread.php?tid=442891)



Banning an IP script - Josh_Main - 09.06.2013

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;
}



Re: Banning an IP script - Aly - 09.06.2013

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.


Re: Banning an IP script - Vince - 09.06.2013

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


Re: Banning an IP script - Josh_Main - 09.06.2013

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


Re: Banning an IP script - Josh_Main - 09.06.2013

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