Raised This Month: $ Target: $400
 0% 

No Permanent Ban


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
P4rD0nM3
Veteran Member
Join Date: Feb 2006
Old 09-21-2007 , 15:51   No Permanent Ban
Reply With Quote #1

Hi guys, I'm trying to edit the admincmd.sma so that the maximum ban would only be a 60 minute ban and not a permanent ban.

Code:
public cmdBan(id, level, cid)
{
	if (!cmd_access(id, level, cid, 3))
		return PLUGIN_HANDLED

	new target[32], minutes[8], reason[64]
	
	read_argv(1, target, 31)
	read_argv(2, minutes, 7)
	read_argv(3, reason, 63)
	
	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("Ban: ^"%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")

	if (reason[0])
		server_cmd("kick #%d ^"%s (%s %s)^";wait;banid ^"%s^" ^"%s^";wait;writeid", userid2, reason, banned, temp, minutes, authid2)
	else
		server_cmd("kick #%d ^"%s %s^";wait;banid ^"%s^" ^"%s^";wait;writeid", userid2, banned, temp, minutes, authid2)

	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
}

public cmdBanIP(id, level, cid)
{
	if (!cmd_access(id, level, cid, 3))
		return PLUGIN_HANDLED
	
	new target[32], minutes[8], reason[64]
	
	read_argv(1, target, 31)
	read_argv(2, minutes, 7)
	read_argv(3, reason, 63)
	
	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("Ban: ^"%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)

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

	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
}
What should replace the else statement so that it won't be a permanent ban but a 60 minute ban? Thanks.
P4rD0nM3 is offline
hoboman
Senior Member
Join Date: Jul 2007
Old 09-21-2007 , 16:49   Re: No Permanent Ban
Reply With Quote #2

lol i know absolutely nothing about scripting but something like this will probably work

after:
Code:
read_argv(2, minutes, 7)
read_argv(3, reason, 63)
put
Code:
if ( minutes > 60 )
    minutes = 60
hoboman is offline
vl@d
Senior Member
Join Date: Dec 2006
Location: Romania
Old 09-21-2007 , 17:11   Re: No Permanent Ban
Reply With Quote #3

actualy that is not true.
Look in amxmod 2006.
you can take the code from there as an ex. ;)
__________________


I hate Spammers....
vl@d is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 09-21-2007 , 17:21   Re: No Permanent Ban
Reply With Quote #4

Quote:
Originally Posted by hoboman View Post
lol i know absolutely nothing about scripting but something like this will probably work

after:
Code:
read_argv(2, minutes, 7)
read_argv(3, reason, 63)
put
Code:
if ( minutes > 60 )
    minutes = 60
Code:
minutes
is a string.
ConnorMcLeod is offline
Alka
AMX Mod X Plugin Approver
Join Date: Dec 2006
Location: malloc(null)
Old 09-21-2007 , 17:30   Re: No Permanent Ban
Reply With Quote #5

Code:
if(str_to_num(minutes) > 60)
{
    minutes = "60";
}
meh...should work.
__________________
Still...lovin' . Connor noob! Hello
Alka is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 09-21-2007 , 17:34   Re: No Permanent Ban
Reply With Quote #6

What would be better is to set the max temp ban in a global or cvar, and only allow perm ban if admin has ADMIN_RCON .
ConnorMcLeod is offline
Alka
AMX Mod X Plugin Approver
Join Date: Dec 2006
Location: malloc(null)
Old 09-21-2007 , 18:19   Re: No Permanent Ban
Reply With Quote #7

Good idea.
Code:
//Global
new cvar_maxbantime;
...
//In plugin_init()
cvar_maxbantime = register_cvar("amx_maxbantime", "60");
...
 
//In Ban Cmd, after reading args...
if(str_to_num(minutes) > get_pcvar_num(cvar_maxbantime) && !(get_user_flags(id) & ADMIN_RCON))
{
    minutes = "60";
}
__________________
Still...lovin' . Connor noob! Hello
Alka is offline
kp_uparrow
Penalized Member
Join Date: Jun 2006
Location: 192.168.0.1
Old 09-21-2007 , 22:48   Re: No Permanent Ban
Reply With Quote #8

you can't just assign strings, u have to use format
__________________
I USED A SECOND ACCOUNT TO DO MORE KARMA UPS AND DOWNS UNTIL GREENTRYST CAUGHT ME
kp_uparrow is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 09-21-2007 , 23:35   Re: No Permanent Ban
Reply With Quote #9

Quote:
Originally Posted by kp_uparrow View Post
you can't just assign strings, u have to use format
minutes = "60";

You're wrong. You can do that for this case.


@Alka.

Don't hardcoding the ban time.

Code:
// -- Global new cvar_maxbantime; [...] // -- In plugin_init() cvar_maxbantime = register_cvar( "amx_maxbantime", "60" ); [...]   // -- In Ban Cmd, after reading args... new cvar_maxbantime = get_pcvar_num( cvar_maxbantime ); if( !( get_user_flags( id ) & ADMIN_RCON ) && str_to_num( minutes ) > cvar_maxbantime ) {     copy( minutes, sizeof minutes - 1, num_to_str( cvar_maxbantime ) ); }
__________________

Last edited by Arkshine; 09-22-2007 at 05:28.
Arkshine is offline
P4rD0nM3
Veteran Member
Join Date: Feb 2006
Old 09-21-2007 , 23:48   Re: No Permanent Ban
Reply With Quote #10

That's after the ban cmd right? The last part.
P4rD0nM3 is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 16:16.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode