Fixed amb1929 - Banning via console should now work properly
authorMatt Schubert <schubertm@gmail.com>
Fri Sep 12 20:36:53 2008 +0000 (2008-09-12)
changeset 2280156053eea73c
parent 2279 d1d825f60854
child 2281 fcb07f41ad91
Fixed amb1929 - Banning via console should now work properly
plugins/basebans/ban.sp
     1.1 --- a/plugins/basebans/ban.sp	Tue Sep 09 02:45:29 2008 +0000
     1.2 +++ b/plugins/basebans/ban.sp	Fri Sep 12 20:36:53 2008 +0000
     1.3 @@ -10,7 +10,7 @@
     1.4   * This program is free software; you can redistribute it and/or modify it under
     1.5   * the terms of the GNU General Public License, version 3.0, as published by the
     1.6   * Free Software Foundation.
     1.7 - * 
     1.8 + *
     1.9   * This program is distributed in the hope that it will be useful, but WITHOUT
    1.10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    1.11   * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
    1.12 @@ -30,17 +30,25 @@
    1.13   *
    1.14   * Version: $Id$
    1.15   */
    1.16 - 
    1.17 +
    1.18  PrepareBan(client, target, time, const String:reason[])
    1.19  {
    1.20  	new originalTarget = GetClientOfUserId(g_BanTargetUserId[client]);
    1.21 -	
    1.22 +
    1.23  	if (originalTarget != target)
    1.24  	{
    1.25 -		PrintToChat(client, "[SM] %t", "Player no longer available");
    1.26 -		return;	
    1.27 +		if (client == 0)
    1.28 +		{
    1.29 +			PrintToServer("[SM] %t", "Player no longer available");
    1.30 +		}
    1.31 +		else
    1.32 +		{
    1.33 +			PrintToChat(client, "[SM] %t", "Player no longer available");
    1.34 +		}
    1.35 +
    1.36 +		return;
    1.37  	}
    1.38 -	
    1.39 +
    1.40  	decl String:authid[64], String:name[32];
    1.41  	GetClientAuthString(target, authid, sizeof(authid));
    1.42  	GetClientName(target, name, sizeof(name));
    1.43 @@ -77,26 +85,26 @@
    1.44  DisplayBanTargetMenu(client)
    1.45  {
    1.46  	new Handle:menu = CreateMenu(MenuHandler_BanPlayerList);
    1.47 -	
    1.48 +
    1.49  	decl String:title[100];
    1.50  	Format(title, sizeof(title), "%T:", "Ban player", client);
    1.51  	SetMenuTitle(menu, title);
    1.52  	SetMenuExitBackButton(menu, true);
    1.53 -	
    1.54 +
    1.55  	AddTargetsToMenu2(menu, client, COMMAND_FILTER_NO_BOTS|COMMAND_FILTER_CONNECTED);
    1.56 -	
    1.57 +
    1.58  	DisplayMenu(menu, client, MENU_TIME_FOREVER);
    1.59  }
    1.60  
    1.61  DisplayBanTimeMenu(client)
    1.62  {
    1.63  	new Handle:menu = CreateMenu(MenuHandler_BanTimeList);
    1.64 -	
    1.65 +
    1.66  	decl String:title[100];
    1.67  	Format(title, sizeof(title), "%T:", "Ban player", client);
    1.68  	SetMenuTitle(menu, title);
    1.69  	SetMenuExitBackButton(menu, true);
    1.70 -	
    1.71 +
    1.72  	AddMenuItem(menu, "0", "Permanent");
    1.73  	AddMenuItem(menu, "10", "10 Minutes");
    1.74  	AddMenuItem(menu, "30", "30 Minutes");
    1.75 @@ -104,21 +112,21 @@
    1.76  	AddMenuItem(menu, "240", "4 Hours");
    1.77  	AddMenuItem(menu, "1440", "1 Day");
    1.78  	AddMenuItem(menu, "10080", "1 Week");
    1.79 -	
    1.80 +
    1.81  	DisplayMenu(menu, client, MENU_TIME_FOREVER);
    1.82  }
    1.83  
    1.84  DisplayBanReasonMenu(client)
    1.85  {
    1.86  	new Handle:menu = CreateMenu(MenuHandler_BanReasonList);
    1.87 -	
    1.88 +
    1.89  	decl String:title[100];
    1.90  	Format(title, sizeof(title), "%T:", "Ban reason", client);
    1.91  	SetMenuTitle(menu, title);
    1.92  	SetMenuExitBackButton(menu, true);
    1.93 -	
    1.94 +
    1.95  	/* :TODO: we should either remove this or make it configurable */
    1.96 -	
    1.97 +
    1.98  	AddMenuItem(menu, "Abusive", "Abusive");
    1.99  	AddMenuItem(menu, "Racism", "Racism");
   1.100  	AddMenuItem(menu, "General cheating/exploits", "General cheating/exploits");
   1.101 @@ -132,11 +140,11 @@
   1.102  	AddMenuItem(menu, "Unacceptable Spray", "Unacceptable Spray");
   1.103  	AddMenuItem(menu, "Breaking Server Rules", "Breaking Server Rules");
   1.104  	AddMenuItem(menu, "Other", "Other");
   1.105 -	
   1.106 +
   1.107  	DisplayMenu(menu, client, MENU_TIME_FOREVER);
   1.108  }
   1.109  
   1.110 -public AdminMenu_Ban(Handle:topmenu, 
   1.111 +public AdminMenu_Ban(Handle:topmenu,
   1.112  							  TopMenuAction:action,
   1.113  							  TopMenuObject:object_id,
   1.114  							  param,
   1.115 @@ -169,9 +177,9 @@
   1.116  	else if (action == MenuAction_Select)
   1.117  	{
   1.118  		decl String:info[64];
   1.119 -		
   1.120 +
   1.121  		GetMenuItem(menu, param2, info, sizeof(info));
   1.122 -	
   1.123 +
   1.124  		PrepareBan(param1, g_BanTarget[param1], g_BanTime[param1], info);
   1.125  	}
   1.126  }
   1.127 @@ -193,7 +201,7 @@
   1.128  	{
   1.129  		decl String:info[32], String:name[32];
   1.130  		new userid, target;
   1.131 -		
   1.132 +
   1.133  		GetMenuItem(menu, param2, info, sizeof(info), _, name, sizeof(name));
   1.134  		userid = StringToInt(info);
   1.135  
   1.136 @@ -230,10 +238,10 @@
   1.137  	else if (action == MenuAction_Select)
   1.138  	{
   1.139  		decl String:info[32];
   1.140 -		
   1.141 +
   1.142  		GetMenuItem(menu, param2, info, sizeof(info));
   1.143  		g_BanTime[param1] = StringToInt(info);
   1.144 -		
   1.145 +
   1.146  		DisplayBanReasonMenu(param1);
   1.147  	}
   1.148  }
   1.149 @@ -246,12 +254,12 @@
   1.150  		ReplyToCommand(client, "[SM] Usage: sm_ban <#userid|name> <minutes|0> [reason]");
   1.151  		return Plugin_Handled;
   1.152  	}
   1.153 -	
   1.154 +
   1.155  	decl len, next_len;
   1.156  	decl String:Arguments[256];
   1.157  	GetCmdArgString(Arguments, sizeof(Arguments));
   1.158  
   1.159 -	decl String:arg[65];	
   1.160 +	decl String:arg[65];
   1.161  	len = BreakString(Arguments, arg, sizeof(arg));
   1.162  
   1.163  	new target = FindTarget(client, arg, true);
   1.164 @@ -273,6 +281,8 @@
   1.165  
   1.166  	new time = StringToInt(s_time);
   1.167  
   1.168 +	g_BanTargetUserId[client] = GetClientUserId(target);
   1.169 +
   1.170  	PrepareBan(client, target, time, Arguments[len]);
   1.171  
   1.172  	return Plugin_Handled;