1.1 --- a/plugins/basecommands.sp Fri Jun 08 01:58:26 2007 +0000
1.2 +++ b/plugins/basecommands.sp Fri Jun 08 03:38:57 2007 +0000
1.3 @@ -43,6 +43,87 @@
1.4 RegAdminCmd("sm_cvar", Command_Cvar, ADMFLAG_CONVARS, "sm_cvar <cvar> [value]");
1.5 RegAdminCmd("sm_execcfg", Command_ExecCfg, ADMFLAG_CONFIG, "sm_execcfg <filename>");
1.6 RegAdminCmd("sm_who", Command_Who, ADMFLAG_GENERIC, "sm_who [#userid|name]");
1.7 + RegAdminCmd("sm_ban", Command_Ban, ADMFLAG_BAN, "sm_ban <#userid|name> <minutes|0> [reason]");
1.8 +}
1.9 +
1.10 +public Action:Command_Ban(client, args)
1.11 +{
1.12 + if (args < 2)
1.13 + {
1.14 + ReplyToCommand(client, "[SM] Usage: sm_ban <#userid|name> <minutes|0> [reason]");
1.15 + return Plugin_Handled;
1.16 + }
1.17 +
1.18 + new String:arg[65];
1.19 + GetCmdArg(1, arg, sizeof(arg));
1.20 +
1.21 + new clients[2];
1.22 + new numClients = SearchForClients(arg, clients, 2);
1.23 +
1.24 + if (numClients == 0)
1.25 + {
1.26 + ReplyToCommand(client, "[SM] %t", "No matching client");
1.27 + return Plugin_Handled;
1.28 + } else if (numClients > 1) {
1.29 + ReplyToCommand(client, "[SM] %t", "More than one client matches", arg);
1.30 + return Plugin_Handled;
1.31 + } else if (!CanUserTarget(client, clients[0])) {
1.32 + ReplyToCommand(client, "[SM] %t", "Unable to target");
1.33 + return Plugin_Handled;
1.34 + } else if (IsFakeClient(clients[0])) {
1.35 + ReplyToCommand(client, "[SM] %t", "Cannot target bot");
1.36 + return Plugin_Handled;
1.37 + }
1.38 +
1.39 + new String:s_time[12];
1.40 + GetCmdArg(2, s_time, sizeof(s_time));
1.41 +
1.42 + new time = StringToInt(s_time);
1.43 +
1.44 + decl String:reason[128];
1.45 + if (args >= 3)
1.46 + {
1.47 + GetCmdArg(3, reason, sizeof(reason));
1.48 + } else {
1.49 + reason[0] = '\0';
1.50 + }
1.51 +
1.52 + new userid = GetClientUserId(clients[0]);
1.53 + GetClientName(clients[0], arg, sizeof(arg));
1.54 +
1.55 + if (time)
1.56 + {
1.57 + if (reason[0] == '\0')
1.58 + {
1.59 + ShowActivity(client, "%t", "Permabanned player", arg);
1.60 + } else {
1.61 + ShowActivity(client, "%t", "Permabanned player reason", arg, reason);
1.62 + }
1.63 + } else {
1.64 + if (reason[0] == '\0')
1.65 + {
1.66 + ShowActivity(client, "%t", "Banned player", arg, time);
1.67 + } else {
1.68 + ShowActivity(client, "%t", "Banned player reason", arg, time, reason);
1.69 + }
1.70 + }
1.71 +
1.72 + LogMessage("\"%L\" banned \"%L\" (minutes \"%d\") (reason \"%s\")", client, clients[0], time, reason);
1.73 +
1.74 + if (reason[0] == '\0')
1.75 + {
1.76 + strcopy(reason, sizeof(reason), "Banned");
1.77 + }
1.78 +
1.79 + ServerCommand("banid %d %d", time, userid);
1.80 + ServerCommand("kickid %d \"%s\"", userid, reason);
1.81 +
1.82 + if (time == 0)
1.83 + {
1.84 + ServerCommand("writeid");
1.85 + }
1.86 +
1.87 + return Plugin_Handled;
1.88 }
1.89
1.90 #define FLAG_STRINGS 14
1.91 @@ -171,13 +252,12 @@
1.92 return Plugin_Handled;
1.93 }
1.94
1.95 + ShowActivity(client, "%t", "Executed config", path[4]);
1.96 +
1.97 LogMessage("\"%L\" executed config (file \"%s\")", client, path[4]);
1.98 - ShowActivity(client, "%t", "Executed config", path[4]);
1.99
1.100 ServerCommand("exec \"%s\"", path[4]);
1.101
1.102 - ReplyToCommand(client, "[SM] %t", "Executed config", path[4]);
1.103 -
1.104 return Plugin_Handled;
1.105 }
1.106
1.107 @@ -244,14 +324,16 @@
1.108
1.109 GetCmdArg(2, value, sizeof(value));
1.110
1.111 - LogMessage("\"%L\" changed cvar (cvar \"%s\") (value \"%s\")", client, cvarname, value);
1.112 if ((GetConVarFlags(hndl) & FCVAR_PROTECTED) != FCVAR_PROTECTED)
1.113 {
1.114 ShowActivity(client, "%t", "Cvar changed", cvarname, value);
1.115 + } else {
1.116 + ReplyToCommand(client, "[SM] %t", "Cvar changed", cvarname, value);
1.117 }
1.118
1.119 + LogMessage("\"%L\" changed cvar (cvar \"%s\") (value \"%s\")", client, cvarname, value);
1.120 +
1.121 SetConVarString(hndl, value);
1.122 - ReplyToCommand(client, "[SM] %t", "Cvar changed", cvarname, value);
1.123
1.124 return Plugin_Handled;
1.125 }
1.126 @@ -268,6 +350,7 @@
1.127 GetCmdArgString(argstring, sizeof(argstring));
1.128
1.129 LogMessage("\"%L\" console command (cmdline \"%s\")", client, argstring);
1.130 +
1.131 ServerCommand("%s", argstring);
1.132
1.133 return Plugin_Handled;
1.134 @@ -290,9 +373,9 @@
1.135 return Plugin_Handled;
1.136 }
1.137
1.138 + ShowActivity(client, "%t", "Changing map", map);
1.139 +
1.140 LogMessage("\"%L\" changed map to \"%s\"", client, map);
1.141 - ShowActivity(client, "%t", "Changing map", map);
1.142 - ReplyToCommand(client, "%t", "Changing map", map);
1.143
1.144 new Handle:dp;
1.145 CreateDataTimer(3.0, Timer_ChangeMap, dp);
1.146 @@ -336,6 +419,7 @@
1.147 return Plugin_Handled;
1.148 } else if (!CanUserTarget(client, clients[0])) {
1.149 ReplyToCommand(client, "[SM] %t", "Unable to target");
1.150 + return Plugin_Handled;
1.151 }
1.152
1.153 new userid = GetClientUserId(clients[0]);
1.154 @@ -352,8 +436,9 @@
1.155 GetCmdArg(2, reason, sizeof(reason));
1.156 }
1.157
1.158 + ShowActivity(client, "%t", "Kicked player", name);
1.159 +
1.160 LogMessage("\"%L\" kicked \"%L\" (reason \"%s\")", client, clients[0], reason);
1.161 - ShowActivity(client, "%t", "Kicked player", name);
1.162
1.163 if (args < 2)
1.164 {
1.165 @@ -362,7 +447,5 @@
1.166 ServerCommand("kickid %d \"%s\"", userid, reason);
1.167 }
1.168
1.169 - ReplyToCommand(client, "[SM] %t", "Client kicked", name);
1.170 -
1.171 return Plugin_Handled;
1.172 }