•  
     

RangeBan - AMXX

Sometimes somebody has a changing IP adress and we need to ban him quickly.

This may be useful when we have a nonsteam server and there is no steamid's and we need to ban by IP addr.

Just type amx_rangeban <name/userid> <range> <minutes> [reason]

If you for example tyle 2 in range parameter then banned ip adres will be 1.2.0.0 (0 means any IP address)
You cannot type more than 3 in range.

Código: Selecionar todos

#include <amxmodx>
#include <amxmisc>

public plugin_init()
{
	register_plugin("RangeBan", "1.0", "neuromancer")
	register_dictionary("admincmd.txt")
	register_dictionary("common.txt")
	register_concmd("amx_rangeban", "cmdRangeBan", ADMIN_BAN, "<name or #userid> <range> <minutes> [reason]")
}

public cmdRangeBan(id, level, cid)
{
	if (!cmd_access(id, level, cid, 3))
		return PLUGIN_HANDLED
	
	new target[32], cmdrange[2], minutes[8], reason[64]
	
	read_argv(1, target, 31)
	read_argv(2, cmdrange, 1)
	read_argv(3, minutes, 7)
	read_argv(4, reason, 63)
	new range = str_to_num(cmdrange[0])
	
	if(range > 3)
	{
		console_print(id, "[AMXX] Range is too big!")
	}
	else {

	new player = cmd_target(id, target, 9)
	
	if (!player)
		return PLUGIN_HANDLED
	
	new authid[32], name2[32], authid2[32], name[32]
	new userid2 = get_user_userid(player)
	
	get_user_authid(player, authid2, 31)
	get_user_authid(id, authid, 31)
	get_user_name(player, name2, 31)
	get_user_name(id, name, 31)
	
	log_amx("RangeBan: ^"%s<%d><%s><>^" ban and kick ^"%s<%d><%s><>^" (minutes ^"%s^") (reason ^"%s^")", name, get_user_userid(id), authid, name2, userid2, authid2, minutes, reason)

	new temp[64], banned[16], nNum = str_to_num(minutes)
	if (nNum)
		format(temp, 63, "%L", player, "FOR_MIN", minutes)
	else
		format(temp, 63, "%L", player, "PERM")
	format(banned, 15, "%L", player, "BANNED")

	new address[32]
	get_user_ip(player, address, 31, 1)
	new ip1[4], ip2[4], ip3[4], ip4[4], tmp1[32], tmp2[32], iptoban[32]
	
	strtok(address, ip1, 3, tmp1, 31, '.')
	strtok(tmp1, ip2, 3, tmp2, 31, '.')
	strtok(tmp2, ip3, 3, ip4, 3, '.')
	if (range == 0)
	{
		format(iptoban, 31, "%s.%s.%s.%s", ip1, ip2, ip3, ip4)
	}
	if(range == 1)
	{
		format(iptoban, 31, "%s.%s.%s.0", ip1, ip2, ip3)
	}
	if(range == 2)
	{
		format(iptoban, 31, "%s.%s.0.0", ip1, ip2)
	}
	if(range == 3)
	{
		format(iptoban, 31, "%s.0.0.0", ip1)
	}

	if (reason[0])
		server_cmd("kick #%d ^"%s (%s %s)^";wait;addip ^"%s^" ^"%s^";wait;writeip", userid2, reason, banned, temp, minutes, iptoban)
	else
		server_cmd("kick #%d ^"%s %s^";wait;addip ^"%s^" ^"%s^";wait;writeip", userid2, banned, temp, minutes, iptoban)

	new activity = get_cvar_num("amx_show_activity")
	if (activity != 0)
	{
		new players[32], pnum, msg[256], len
		get_players(players, pnum, "c")
		
		for (new i = 0; i < pnum; i++)
		{
			len = format(msg, 255, "%L", players[i], "ADMIN")
			
			if (activity == 1)
				len += copy(msg[len], 255-len, ":")
			else
				len += format(msg[len], 255-len, " %s:", name)
			
			len += format(msg[len], 255-len, " %L", players[i], "BAN")
			len += format(msg[len], 255-len, " %s ", name2)
		
			if (nNum)
				format(msg[len], 255-len, "%L", players[i], "FOR_MIN", minutes)
			else
				format(msg[len], 255-len, "%L", players[i], "PERM")
			
			client_print(players[i], print_chat, "%s", msg)
		}
	}
	console_print(id, "[AMXX] %L", id, "CLIENT_BANNED", name2)
	}
	return PLUGIN_HANDLED
}


Ressuscitado pela última vez por Anderson em 05 jun 2015 14:57.