plugins/basecommands.sp
changeset 1423 e73b3563f254
parent 1417 79f72a315320
child 1510 de71b8774afc
     1.1 --- a/plugins/basecommands.sp	Thu Sep 13 18:29:04 2007 +0000
     1.2 +++ b/plugins/basecommands.sp	Fri Sep 14 02:11:10 2007 +0000
     1.3 @@ -44,10 +44,6 @@
     1.4  	url = "http://www.sourcemod.net/"
     1.5  };
     1.6  
     1.7 -new Handle:hBanForward = INVALID_HANDLE;
     1.8 -new Handle:hAddBanForward = INVALID_HANDLE;
     1.9 -new Handle:hBanRemoved = INVALID_HANDLE;
    1.10 -
    1.11  public OnPluginStart()
    1.12  {
    1.13  	LoadTranslations("common.phrases");
    1.14 @@ -58,16 +54,8 @@
    1.15  	RegAdminCmd("sm_cvar", Command_Cvar, ADMFLAG_CONVARS, "sm_cvar <cvar> [value]");
    1.16  	RegAdminCmd("sm_execcfg", Command_ExecCfg, ADMFLAG_CONFIG, "sm_execcfg <filename>");
    1.17  	RegAdminCmd("sm_who", Command_Who, ADMFLAG_GENERIC, "sm_who [#userid|name]");
    1.18 -	RegAdminCmd("sm_ban", Command_Ban, ADMFLAG_BAN, "sm_ban <#userid|name> <minutes|0> [reason]");
    1.19 -	RegAdminCmd("sm_unban", Command_Unban, ADMFLAG_UNBAN, "sm_unban <steamid>");
    1.20 -	RegAdminCmd("sm_addban", Command_AddBan, ADMFLAG_RCON, "sm_addban <time> <steamid> [reason]");
    1.21 -	RegAdminCmd("sm_banip", Command_BanIp, ADMFLAG_BAN, "sm_banip <time> <ip|#userid|name> [reason]");
    1.22  	RegAdminCmd("sm_reloadadmins", Command_ReloadAdmins, ADMFLAG_BAN, "sm_reloadadmins");
    1.23  	RegAdminCmd("sm_cancelvote", Command_CancelVote, ADMFLAG_VOTE, "sm_cancelvote");
    1.24 -	
    1.25 -	hBanForward = CreateGlobalForward("OnClientBanned", ET_Hook, Param_Cell, Param_Cell, Param_Cell, Param_String);
    1.26 -	hAddBanForward = CreateGlobalForward("OnBanAdded", ET_Hook, Param_Cell, Param_String, Param_Cell, Param_String);
    1.27 -	hBanRemoved = CreateGlobalForward("OnBanRemoved", ET_Hook, Param_Cell, Param_String);
    1.28  }
    1.29  
    1.30  public Action:Command_ReloadAdmins(client, args)
    1.31 @@ -82,263 +70,6 @@
    1.32  	return Plugin_Handled;
    1.33  }
    1.34  
    1.35 -public Action:Command_BanIp(client, args)
    1.36 -{
    1.37 -	if (args < 2)
    1.38 -	{
    1.39 -		ReplyToCommand(client, "[SM] Usage: sm_banip <time> <ip|#userid|name> [reason]");
    1.40 -		return Plugin_Handled;
    1.41 -	}
    1.42 -
    1.43 -	decl String:arg[50], String:time[20];
    1.44 -	GetCmdArg(1, time, sizeof(time));
    1.45 -	GetCmdArg(2, arg, sizeof(arg));
    1.46 -	
    1.47 -	if (StrEqual(arg, "0"))
    1.48 -	{
    1.49 -		ReplyToCommand(client, "[SM] %t", "Cannot ban that IP");
    1.50 -		return Plugin_Handled;
    1.51 -	}
    1.52 -	
    1.53 -	new clients[1];
    1.54 -	new numClients = SearchForClients(arg, clients, 1);
    1.55 -
    1.56 -	new bool:has_rcon;
    1.57 -	
    1.58 -	if (client == 0 || (client == 1 && !IsDedicatedServer()))
    1.59 -	{
    1.60 -		has_rcon = true;
    1.61 -	} else {
    1.62 -		new AdminId:id = GetUserAdmin(client);
    1.63 -		has_rcon = (id == INVALID_ADMIN_ID) ? false : GetAdminFlag(id, Admin_RCON);
    1.64 -	}
    1.65 -	
    1.66 -	new hit_client = -1;
    1.67 -	if (numClients == 1 
    1.68 -		&& !IsFakeClient(clients[0])
    1.69 -		&& (has_rcon || CanUserTarget(client, clients[0])))
    1.70 -	{
    1.71 -		GetClientIP(clients[0], arg, sizeof(arg));
    1.72 -		hit_client = clients[0];
    1.73 -	}
    1.74 -	
    1.75 -	if (hit_client == -1 && !has_rcon)
    1.76 -	{
    1.77 -		ReplyToCommand(client, "[SM] %t", "No Access");
    1.78 -		return Plugin_Handled;
    1.79 -	}
    1.80 -
    1.81 -	new minutes = StringToInt(time);
    1.82 -
    1.83 -	decl String:reason[128];
    1.84 -	if (args >= 3)
    1.85 -	{
    1.86 -		GetCmdArg(3, reason, sizeof(reason));
    1.87 -	}
    1.88 -
    1.89 -	new Action:act = Plugin_Continue;
    1.90 -	Call_StartForward(hAddBanForward);
    1.91 -	Call_PushCell(client);
    1.92 -	Call_PushString(arg);
    1.93 -	Call_PushCell(minutes);
    1.94 -	Call_PushString(reason);
    1.95 -	Call_Finish(act);
    1.96 -
    1.97 -	if (act < Plugin_Handled)
    1.98 -	{
    1.99 -		LogAction(client, hit_client, "\"%L\" added ban (minutes \"%d\") (ip \"%s\") (reason \"%s\")", client, minutes, arg, reason);
   1.100 -		ReplyToCommand(client, "[SM] %t", "Ban added");
   1.101 -	}
   1.102 -
   1.103 -	if (act < Plugin_Stop)
   1.104 -	{
   1.105 -		ServerCommand("addip %d %s", minutes, arg);
   1.106 -		ServerCommand("writeip");
   1.107 -	}
   1.108 -
   1.109 -	return Plugin_Handled;
   1.110 -}
   1.111 -
   1.112 -public Action:Command_AddBan(client, args)
   1.113 -{
   1.114 -	if (args < 2)
   1.115 -	{
   1.116 -		ReplyToCommand(client, "[SM] Usage: sm_addban <time> <steamid> [reason]");
   1.117 -		return Plugin_Handled;
   1.118 -	}
   1.119 -
   1.120 -	decl String:arg[50], String:time[20];
   1.121 -	GetCmdArg(1, time, sizeof(time));
   1.122 -	GetCmdArg(2, arg, sizeof(arg));
   1.123 -
   1.124 -	new minutes = StringToInt(time);
   1.125 -
   1.126 -	new String:reason[128];
   1.127 -	if (args >= 3)
   1.128 -	{
   1.129 -		GetCmdArg(3, reason, sizeof(reason));
   1.130 -	}
   1.131 -
   1.132 -	new Action:act = Plugin_Continue;
   1.133 -	Call_StartForward(hAddBanForward);
   1.134 -	Call_PushCell(client);
   1.135 -	Call_PushString(arg);
   1.136 -	Call_PushCell(minutes);
   1.137 -	Call_PushString(reason);
   1.138 -	Call_Finish(act);
   1.139 -
   1.140 -	if (act < Plugin_Handled)
   1.141 -	{
   1.142 -		LogAction(client, -1, "\"%L\" added ban (minutes \"%d\") (id \"%s\") (reason \"%s\")", client, minutes, arg, reason);
   1.143 -		ReplyToCommand(client, "[SM] %t", "Ban added");
   1.144 -	}
   1.145 -
   1.146 -	if (act < Plugin_Stop)
   1.147 -	{
   1.148 -		ServerCommand("banid %d %s", minutes, arg);
   1.149 -		ServerCommand("writeid");
   1.150 -	}
   1.151 -
   1.152 -	return Plugin_Handled;
   1.153 -}
   1.154 -
   1.155 -public Action:Command_Unban(client, args)
   1.156 -{
   1.157 -	if (args < 1)
   1.158 -	{
   1.159 -		ReplyToCommand(client, "[SM] Usage: sm_unban <steamid>");
   1.160 -		return Plugin_Handled;
   1.161 -	}
   1.162 -
   1.163 -	decl String:arg[50], String:new_arg[50];
   1.164 -	new start=0;
   1.165 -	GetCmdArgString(arg, sizeof(arg));
   1.166 -
   1.167 -	if(arg[start] == '"')
   1.168 -	{
   1.169 -		start++;
   1.170 -	}
   1.171 -
   1.172 -	if (strncmp(arg[start], "STEAM_0:", 8, false) == 0)
   1.173 -	{
   1.174 -		start += 8;
   1.175 -	} else if (strncmp(arg[start], "0:1:", 4) == 0 || strncmp(arg[start], "0:0:", 4) == 0) {
   1.176 -		start += 2;
   1.177 -	}
   1.178 -
   1.179 -	Format(new_arg, sizeof(new_arg), "STEAM_0:%s", arg[start]);
   1.180 -
   1.181 -	/* Remove white spaces */
   1.182 -	new len = TrimString(new_arg);
   1.183 -	if(new_arg[len - 1] == '"')
   1.184 -	{
   1.185 -		new_arg[len - 1] = '\0';
   1.186 -	}
   1.187 -
   1.188 -	new Action:act = Plugin_Continue;
   1.189 -	Call_StartForward(hBanRemoved);
   1.190 -	Call_PushCell(client);
   1.191 -	Call_PushString(new_arg);
   1.192 -	Call_Finish(act);
   1.193 -
   1.194 -	if (act < Plugin_Handled)
   1.195 -	{
   1.196 -		LogAction(client, -1, "\"%L\" removed ban (filter \"%s\")", client, new_arg);
   1.197 -		ReplyToCommand(client, "[SM] %t", "Removed bans matching", new_arg);
   1.198 -	}
   1.199 -
   1.200 -	if (act < Plugin_Stop)
   1.201 -	{
   1.202 -		ServerCommand("removeid %s", new_arg);
   1.203 -		ServerCommand("writeid");
   1.204 -	}
   1.205 -
   1.206 -	return Plugin_Handled;
   1.207 -}
   1.208 -
   1.209 -public Action:Command_Ban(client, args)
   1.210 -{
   1.211 -	if (args < 2)
   1.212 -	{
   1.213 -		ReplyToCommand(client, "[SM] Usage: sm_ban <#userid|name> <minutes|0> [reason]");
   1.214 -		return Plugin_Handled;
   1.215 -	}
   1.216 -
   1.217 -	decl String:arg[65];
   1.218 -	GetCmdArg(1, arg, sizeof(arg));
   1.219 -
   1.220 -	new target = FindTarget(client, arg, true);
   1.221 -	if (target == -1)
   1.222 -	{
   1.223 -		return Plugin_Handled;
   1.224 -	}
   1.225 -
   1.226 -	decl String:s_time[12];
   1.227 -	GetCmdArg(2, s_time, sizeof(s_time));
   1.228 -
   1.229 -	new time = StringToInt(s_time);
   1.230 -
   1.231 -	decl String:reason[128];
   1.232 -	if (args >= 3)
   1.233 -	{
   1.234 -		GetCmdArg(3, reason, sizeof(reason));
   1.235 -	} else {
   1.236 -		reason[0] = '\0';
   1.237 -	}
   1.238 -
   1.239 -	decl String:authid[64];
   1.240 -	GetClientAuthString(target, authid, sizeof(authid));
   1.241 -	GetClientName(target, arg, sizeof(arg));
   1.242 -
   1.243 -	/* Fire the ban forward */
   1.244 -	new Action:act = Plugin_Continue;
   1.245 -	Call_StartForward(hBanForward);
   1.246 -	Call_PushCell(client);
   1.247 -	Call_PushCell(target);
   1.248 -	Call_PushCell(time);
   1.249 -	Call_PushString(reason);
   1.250 -	Call_Finish(act);
   1.251 -
   1.252 -	if (act < Plugin_Handled)
   1.253 -	{
   1.254 -		if (!time)
   1.255 -		{
   1.256 -			if (reason[0] == '\0')
   1.257 -			{
   1.258 -				ShowActivity(client, "%t", "Permabanned player", arg);
   1.259 -			} else {
   1.260 -				ShowActivity(client, "%t", "Permabanned player reason", arg, reason);
   1.261 -			}
   1.262 -		} else {
   1.263 -			if (reason[0] == '\0')
   1.264 -			{
   1.265 -				ShowActivity(client, "%t", "Banned player", arg, time);
   1.266 -			} else {
   1.267 -				ShowActivity(client, "%t", "Banned player reason", arg, time, reason);
   1.268 -			}
   1.269 -		}
   1.270 -		LogAction(client, target, "\"%L\" banned \"%L\" (minutes \"%d\") (reason \"%s\")", client, target, time, reason);
   1.271 -	}
   1.272 -
   1.273 -	if (act < Plugin_Stop)
   1.274 -	{
   1.275 -		if (reason[0] == '\0')
   1.276 -		{
   1.277 -			strcopy(reason, sizeof(reason), "Banned");
   1.278 -		}
   1.279 -
   1.280 -		ServerCommand("banid %d %s", time, authid);
   1.281 -		KickClient(target, "%s", reason);
   1.282 -
   1.283 -		if (time == 0)
   1.284 -		{
   1.285 -			ServerCommand("writeid");
   1.286 -		}
   1.287 -	}
   1.288 -
   1.289 -	return Plugin_Handled;
   1.290 -}
   1.291 -
   1.292  #define FLAG_STRINGS		14
   1.293  new String:g_FlagNames[FLAG_STRINGS][20] =
   1.294  {