basecommands.sp: Removed plugin.basecommands.txt, switched to FindTarget stock, and added a 2 minute IP ban to sm_ban to stop retry spammers.
basecommands.sp: Removed plugin.basecommands.txt, switched to FindTarget stock, and added a 2 minute IP ban to sm_ban to stop retry spammers.
1.1 --- a/plugins/basecommands.sp Fri Jul 27 21:27:56 2007 +0000
1.2 +++ b/plugins/basecommands.sp Fri Jul 27 22:30:05 2007 +0000
1.3 @@ -40,7 +40,7 @@
1.4 public OnPluginStart()
1.5 {
1.6 LoadTranslations("common.phrases");
1.7 - LoadTranslations("plugin.basecommands");
1.8 +
1.9 RegAdminCmd("sm_kick", Command_Kick, ADMFLAG_KICK, "sm_kick <#userid|name> [reason]");
1.10 RegAdminCmd("sm_map", Command_Map, ADMFLAG_CHANGEMAP, "sm_map <map>");
1.11 RegAdminCmd("sm_rcon", Command_Rcon, ADMFLAG_RCON, "sm_rcon <args>");
1.12 @@ -211,21 +211,9 @@
1.13 decl String:arg[65];
1.14 GetCmdArg(1, arg, sizeof(arg));
1.15
1.16 - new clients[2];
1.17 - new numClients = SearchForClients(arg, clients, 2);
1.18 -
1.19 - if (numClients == 0)
1.20 + new target = FindTarget(client, arg, true);
1.21 + if (target == -1)
1.22 {
1.23 - ReplyToCommand(client, "[SM] %t", "No matching client");
1.24 - return Plugin_Handled;
1.25 - } else if (numClients > 1) {
1.26 - ReplyToCommand(client, "[SM] %t", "More than one client matches", arg);
1.27 - return Plugin_Handled;
1.28 - } else if (!CanUserTarget(client, clients[0])) {
1.29 - ReplyToCommand(client, "[SM] %t", "Unable to target");
1.30 - return Plugin_Handled;
1.31 - } else if (IsFakeClient(clients[0])) {
1.32 - ReplyToCommand(client, "[SM] %t", "Cannot target bot");
1.33 return Plugin_Handled;
1.34 }
1.35
1.36 @@ -233,6 +221,7 @@
1.37 GetCmdArg(2, s_time, sizeof(s_time));
1.38
1.39 new time = StringToInt(s_time);
1.40 + new iptime = (time < 2 ? time : 2);
1.41
1.42 decl String:reason[128];
1.43 if (args >= 3)
1.44 @@ -242,15 +231,16 @@
1.45 reason[0] = '\0';
1.46 }
1.47
1.48 - decl String:authid[64];
1.49 - GetClientAuthString(clients[0], authid, sizeof(authid));
1.50 - GetClientName(clients[0], arg, sizeof(arg));
1.51 + decl String:authid[64], String:ip[50];
1.52 + GetClientAuthString(target, authid, sizeof(authid));
1.53 + GetClientIP(target, ip, sizeof(ip));
1.54 + GetClientName(target, arg, sizeof(arg));
1.55
1.56 /* Fire the ban forward */
1.57 new Action:act = Plugin_Continue;
1.58 Call_StartForward(hBanForward);
1.59 Call_PushCell(client);
1.60 - Call_PushCell(clients[0]);
1.61 + Call_PushCell(target);
1.62 Call_PushCell(time);
1.63 Call_PushString(reason);
1.64 Call_Finish(act);
1.65 @@ -273,7 +263,7 @@
1.66 ShowActivity(client, "%t", "Banned player reason", arg, time, reason);
1.67 }
1.68 }
1.69 - LogMessage("\"%L\" banned \"%L\" (minutes \"%d\") (reason \"%s\")", client, clients[0], time, reason);
1.70 + LogMessage("\"%L\" banned \"%L\" (minutes \"%d\") (reason \"%s\")", client, target, time, reason);
1.71 }
1.72
1.73 if (act < Plugin_Stop)
1.74 @@ -283,8 +273,9 @@
1.75 strcopy(reason, sizeof(reason), "Banned");
1.76 }
1.77
1.78 + ServerCommand("banip %d %s", iptime, ip);
1.79 ServerCommand("banid %d %s", time, authid);
1.80 - KickClient(clients[0], "%s", reason);
1.81 + KickClient(target, "%s", reason);
1.82
1.83 if (time == 0)
1.84 {
1.85 @@ -577,24 +568,16 @@
1.86 decl String:arg[65];
1.87 GetCmdArg(1, arg, sizeof(arg));
1.88
1.89 - new clients[2];
1.90 - new numClients = SearchForClients(arg, clients, 2);
1.91
1.92 - if (numClients == 0)
1.93 + new target = FindTarget(client, arg);
1.94 + if (target == -1)
1.95 {
1.96 - ReplyToCommand(client, "[SM] %t", "No matching client");
1.97 - return Plugin_Handled;
1.98 - } else if (numClients > 1) {
1.99 - ReplyToCommand(client, "[SM] %t", "More than one client matches", arg);
1.100 - return Plugin_Handled;
1.101 - } else if (!CanUserTarget(client, clients[0])) {
1.102 - ReplyToCommand(client, "[SM] %t", "Unable to target");
1.103 return Plugin_Handled;
1.104 }
1.105
1.106 decl String:name[65];
1.107
1.108 - GetClientName(clients[0], name, sizeof(name));
1.109 + GetClientName(target, name, sizeof(name));
1.110
1.111 decl String:reason[256];
1.112 if (args < 2)
1.113 @@ -607,9 +590,9 @@
1.114
1.115 ShowActivity(client, "%t", "Kicked player", name);
1.116
1.117 - LogMessage("\"%L\" kicked \"%L\" (reason \"%s\")", client, clients[0], reason);
1.118 + LogMessage("\"%L\" kicked \"%L\" (reason \"%s\")", client, target, reason);
1.119
1.120 - KickClient(clients[0], "%s", reason);
1.121 + KickClient(target, "%s", reason);
1.122
1.123 return Plugin_Handled;
1.124 }