1.1 --- a/core/smn_player.cpp Fri Jun 08 01:58:26 2007 +0000
1.2 +++ b/core/smn_player.cpp Fri Jun 08 03:38:57 2007 +0000
1.3 @@ -18,6 +18,7 @@
1.4 #include "HalfLife2.h"
1.5 #include "sourcemod.h"
1.6 #include <inetchannelinfo.h>
1.7 +#include "ChatTriggers.h"
1.8
1.9 ConVar sm_show_activity("sm_show_activity", "13", FCVAR_SPONLY|FCVAR_PROTECTED, "Activity display setting (see sourcemod.cfg)");
1.10
1.11 @@ -822,17 +823,15 @@
1.12
1.13 static cell_t ShowActivity(IPluginContext *pContext, const cell_t *params)
1.14 {
1.15 + char message[255];
1.16 + char buffer[255];
1.17 int value = sm_show_activity.GetInt();
1.18 -
1.19 - if (!value)
1.20 - {
1.21 - return 0;
1.22 - }
1.23 -
1.24 + unsigned int replyto = g_ChatTriggers.GetReplyTo();
1.25 int client = params[1];
1.26
1.27 const char *name = "Console";
1.28 const char *sign = "ADMIN";
1.29 + bool display_in_chat = false;
1.30 if (client != 0)
1.31 {
1.32 CPlayer *pPlayer = g_Players.GetPlayerByIndex(client);
1.33 @@ -847,15 +846,35 @@
1.34 {
1.35 sign = "PLAYER";
1.36 }
1.37 +
1.38 + /* Display the message to the client? */
1.39 + if (replyto == SM_REPLY_CONSOLE)
1.40 + {
1.41 + g_SourceMod.SetGlobalTarget(client);
1.42 + g_SourceMod.FormatString(buffer, sizeof(buffer), pContext, params, 2);
1.43 + UTIL_Format(message, sizeof(message), "[SM] %s\n", buffer);
1.44 + engine->ClientPrintf(pPlayer->GetEdict(), message);
1.45 + display_in_chat = true;
1.46 + }
1.47 + } else {
1.48 + g_SourceMod.SetGlobalTarget(LANG_SERVER);
1.49 + g_SourceMod.FormatString(buffer, sizeof(buffer), pContext, params, 2);
1.50 + UTIL_Format(message, sizeof(message), "[SM] %s\n", buffer);
1.51 + META_CONPRINT(message);
1.52 }
1.53
1.54 - char message[255];
1.55 - char buffer[255];
1.56 + if (!value)
1.57 + {
1.58 + return 1;
1.59 + }
1.60 +
1.61 int maxClients = g_Players.GetMaxClients();
1.62 for (int i=1; i<=maxClients; i++)
1.63 {
1.64 CPlayer *pPlayer = g_Players.GetPlayerByIndex(i);
1.65 - if (!pPlayer->IsInGame() || pPlayer->IsFakeClient())
1.66 + if (!pPlayer->IsInGame()
1.67 + || pPlayer->IsFakeClient()
1.68 + || (display_in_chat && i == client))
1.69 {
1.70 continue;
1.71 }
2.1 --- a/plugins/basecommands.sp Fri Jun 08 01:58:26 2007 +0000
2.2 +++ b/plugins/basecommands.sp Fri Jun 08 03:38:57 2007 +0000
2.3 @@ -43,6 +43,87 @@
2.4 RegAdminCmd("sm_cvar", Command_Cvar, ADMFLAG_CONVARS, "sm_cvar <cvar> [value]");
2.5 RegAdminCmd("sm_execcfg", Command_ExecCfg, ADMFLAG_CONFIG, "sm_execcfg <filename>");
2.6 RegAdminCmd("sm_who", Command_Who, ADMFLAG_GENERIC, "sm_who [#userid|name]");
2.7 + RegAdminCmd("sm_ban", Command_Ban, ADMFLAG_BAN, "sm_ban <#userid|name> <minutes|0> [reason]");
2.8 +}
2.9 +
2.10 +public Action:Command_Ban(client, args)
2.11 +{
2.12 + if (args < 2)
2.13 + {
2.14 + ReplyToCommand(client, "[SM] Usage: sm_ban <#userid|name> <minutes|0> [reason]");
2.15 + return Plugin_Handled;
2.16 + }
2.17 +
2.18 + new String:arg[65];
2.19 + GetCmdArg(1, arg, sizeof(arg));
2.20 +
2.21 + new clients[2];
2.22 + new numClients = SearchForClients(arg, clients, 2);
2.23 +
2.24 + if (numClients == 0)
2.25 + {
2.26 + ReplyToCommand(client, "[SM] %t", "No matching client");
2.27 + return Plugin_Handled;
2.28 + } else if (numClients > 1) {
2.29 + ReplyToCommand(client, "[SM] %t", "More than one client matches", arg);
2.30 + return Plugin_Handled;
2.31 + } else if (!CanUserTarget(client, clients[0])) {
2.32 + ReplyToCommand(client, "[SM] %t", "Unable to target");
2.33 + return Plugin_Handled;
2.34 + } else if (IsFakeClient(clients[0])) {
2.35 + ReplyToCommand(client, "[SM] %t", "Cannot target bot");
2.36 + return Plugin_Handled;
2.37 + }
2.38 +
2.39 + new String:s_time[12];
2.40 + GetCmdArg(2, s_time, sizeof(s_time));
2.41 +
2.42 + new time = StringToInt(s_time);
2.43 +
2.44 + decl String:reason[128];
2.45 + if (args >= 3)
2.46 + {
2.47 + GetCmdArg(3, reason, sizeof(reason));
2.48 + } else {
2.49 + reason[0] = '\0';
2.50 + }
2.51 +
2.52 + new userid = GetClientUserId(clients[0]);
2.53 + GetClientName(clients[0], arg, sizeof(arg));
2.54 +
2.55 + if (time)
2.56 + {
2.57 + if (reason[0] == '\0')
2.58 + {
2.59 + ShowActivity(client, "%t", "Permabanned player", arg);
2.60 + } else {
2.61 + ShowActivity(client, "%t", "Permabanned player reason", arg, reason);
2.62 + }
2.63 + } else {
2.64 + if (reason[0] == '\0')
2.65 + {
2.66 + ShowActivity(client, "%t", "Banned player", arg, time);
2.67 + } else {
2.68 + ShowActivity(client, "%t", "Banned player reason", arg, time, reason);
2.69 + }
2.70 + }
2.71 +
2.72 + LogMessage("\"%L\" banned \"%L\" (minutes \"%d\") (reason \"%s\")", client, clients[0], time, reason);
2.73 +
2.74 + if (reason[0] == '\0')
2.75 + {
2.76 + strcopy(reason, sizeof(reason), "Banned");
2.77 + }
2.78 +
2.79 + ServerCommand("banid %d %d", time, userid);
2.80 + ServerCommand("kickid %d \"%s\"", userid, reason);
2.81 +
2.82 + if (time == 0)
2.83 + {
2.84 + ServerCommand("writeid");
2.85 + }
2.86 +
2.87 + return Plugin_Handled;
2.88 }
2.89
2.90 #define FLAG_STRINGS 14
2.91 @@ -171,13 +252,12 @@
2.92 return Plugin_Handled;
2.93 }
2.94
2.95 + ShowActivity(client, "%t", "Executed config", path[4]);
2.96 +
2.97 LogMessage("\"%L\" executed config (file \"%s\")", client, path[4]);
2.98 - ShowActivity(client, "%t", "Executed config", path[4]);
2.99
2.100 ServerCommand("exec \"%s\"", path[4]);
2.101
2.102 - ReplyToCommand(client, "[SM] %t", "Executed config", path[4]);
2.103 -
2.104 return Plugin_Handled;
2.105 }
2.106
2.107 @@ -244,14 +324,16 @@
2.108
2.109 GetCmdArg(2, value, sizeof(value));
2.110
2.111 - LogMessage("\"%L\" changed cvar (cvar \"%s\") (value \"%s\")", client, cvarname, value);
2.112 if ((GetConVarFlags(hndl) & FCVAR_PROTECTED) != FCVAR_PROTECTED)
2.113 {
2.114 ShowActivity(client, "%t", "Cvar changed", cvarname, value);
2.115 + } else {
2.116 + ReplyToCommand(client, "[SM] %t", "Cvar changed", cvarname, value);
2.117 }
2.118
2.119 + LogMessage("\"%L\" changed cvar (cvar \"%s\") (value \"%s\")", client, cvarname, value);
2.120 +
2.121 SetConVarString(hndl, value);
2.122 - ReplyToCommand(client, "[SM] %t", "Cvar changed", cvarname, value);
2.123
2.124 return Plugin_Handled;
2.125 }
2.126 @@ -268,6 +350,7 @@
2.127 GetCmdArgString(argstring, sizeof(argstring));
2.128
2.129 LogMessage("\"%L\" console command (cmdline \"%s\")", client, argstring);
2.130 +
2.131 ServerCommand("%s", argstring);
2.132
2.133 return Plugin_Handled;
2.134 @@ -290,9 +373,9 @@
2.135 return Plugin_Handled;
2.136 }
2.137
2.138 + ShowActivity(client, "%t", "Changing map", map);
2.139 +
2.140 LogMessage("\"%L\" changed map to \"%s\"", client, map);
2.141 - ShowActivity(client, "%t", "Changing map", map);
2.142 - ReplyToCommand(client, "%t", "Changing map", map);
2.143
2.144 new Handle:dp;
2.145 CreateDataTimer(3.0, Timer_ChangeMap, dp);
2.146 @@ -336,6 +419,7 @@
2.147 return Plugin_Handled;
2.148 } else if (!CanUserTarget(client, clients[0])) {
2.149 ReplyToCommand(client, "[SM] %t", "Unable to target");
2.150 + return Plugin_Handled;
2.151 }
2.152
2.153 new userid = GetClientUserId(clients[0]);
2.154 @@ -352,8 +436,9 @@
2.155 GetCmdArg(2, reason, sizeof(reason));
2.156 }
2.157
2.158 + ShowActivity(client, "%t", "Kicked player", name);
2.159 +
2.160 LogMessage("\"%L\" kicked \"%L\" (reason \"%s\")", client, clients[0], reason);
2.161 - ShowActivity(client, "%t", "Kicked player", name);
2.162
2.163 if (args < 2)
2.164 {
2.165 @@ -362,7 +447,5 @@
2.166 ServerCommand("kickid %d \"%s\"", userid, reason);
2.167 }
2.168
2.169 - ReplyToCommand(client, "[SM] %t", "Client kicked", name);
2.170 -
2.171 return Plugin_Handled;
2.172 }
3.1 --- a/plugins/include/console.inc Fri Jun 08 01:58:26 2007 +0000
3.2 +++ b/plugins/include/console.inc Fri Jun 08 03:38:57 2007 +0000
3.3 @@ -185,7 +185,9 @@
3.4
3.5 /**
3.6 * Displays usage of an admin command to users depending on the
3.7 - * setting of the sm_show_activity cvar.
3.8 + * setting of the sm_show_activity cvar. Additionally, the client
3.9 + * who typed the command will receive the same text without any
3.10 + * client name prefix (as a confirmation).
3.11 *
3.12 * @param client Client index doing the action, or 0 for server.
3.13 * @param format Formatting rules.
4.1 --- a/translations/common.cfg Fri Jun 08 01:58:26 2007 +0000
4.2 +++ b/translations/common.cfg Fri Jun 08 03:38:57 2007 +0000
4.3 @@ -17,12 +17,6 @@
4.4 "en" "Kicked player '{1}'"
4.5 }
4.6
4.7 - "Client kicked"
4.8 - {
4.9 - "#format" "{1:s}"
4.10 - "en" "Client '{1}' kicked."
4.11 - }
4.12 -
4.13 "Changing map"
4.14 {
4.15 "#format" "{1:s}"
4.16 @@ -54,4 +48,9 @@
4.17 {
4.18 "en" "See console for output."
4.19 }
4.20 +
4.21 + "Cannot target bot"
4.22 + {
4.23 + "en" "Unable to perform this command on a bot."
4.24 + }
4.25 }
5.1 --- a/translations/plugin.basecommands.cfg Fri Jun 08 01:58:26 2007 +0000
5.2 +++ b/translations/plugin.basecommands.cfg Fri Jun 08 03:38:57 2007 +0000
5.3 @@ -34,4 +34,28 @@
5.4 "#format" "{1:s}"
5.5 "en" "Executed config '{1}'."
5.6 }
5.7 +
5.8 + "Permabanned player"
5.9 + {
5.10 + "#format" "{1:s}"
5.11 + "en" "Permanently banned player '{1}'."
5.12 + }
5.13 +
5.14 + "Permabanned player reason"
5.15 + {
5.16 + "#format" "{1:s},{2:s}"
5.17 + "en" "Permanently banned player '{1}' (reason: {2})."
5.18 + }
5.19 +
5.20 + "Banned player"
5.21 + {
5.22 + "#format" "{1:s},{2:d}"
5.23 + "en" "Banned player '{1}' for {2} minutes."
5.24 + }
5.25 +
5.26 + "Banned player reason"
5.27 + {
5.28 + "#format" "{1:s},{2:d},{3:s}"
5.29 + "en" "Banned player '{1}' for {2} minutes (reason: {3})."
5.30 + }
5.31 }