1.1 --- a/core/smn_console.cpp Fri Jun 08 01:09:17 2007 +0000
1.2 +++ b/core/smn_console.cpp Fri Jun 08 01:58:26 2007 +0000
1.3 @@ -706,6 +706,11 @@
1.4 return 1;
1.5 }
1.6
1.7 +static cell_t GetCmdReplyTarget(IPluginContext *pContext, const cell_t *params)
1.8 +{
1.9 + return g_ChatTriggers.GetReplyTo();
1.10 +}
1.11 +
1.12 REGISTER_NATIVES(consoleNatives)
1.13 {
1.14 {"CreateConVar", sm_CreateConVar},
1.15 @@ -741,5 +746,6 @@
1.16 {"ClientCommand", sm_ClientCommand},
1.17 {"FakeClientCommand", FakeClientCommand},
1.18 {"ReplyToCommand", ReplyToCommand},
1.19 + {"GetCmdReplySource", GetCmdReplyTarget},
1.20 {NULL, NULL}
1.21 };
2.1 --- a/core/smn_player.cpp Fri Jun 08 01:09:17 2007 +0000
2.2 +++ b/core/smn_player.cpp Fri Jun 08 01:58:26 2007 +0000
2.3 @@ -19,7 +19,7 @@
2.4 #include "sourcemod.h"
2.5 #include <inetchannelinfo.h>
2.6
2.7 -ConVar sm_show_activity("sm_show_activity", "13", FCVAR_SPONLY, "Activity display setting (see sourcemod.cfg)");
2.8 +ConVar sm_show_activity("sm_show_activity", "13", FCVAR_SPONLY|FCVAR_PROTECTED, "Activity display setting (see sourcemod.cfg)");
2.9
2.10 static cell_t sm_GetClientCount(IPluginContext *pCtx, const cell_t *params)
2.11 {
3.1 --- a/plugins/basecommands.sp Fri Jun 08 01:09:17 2007 +0000
3.2 +++ b/plugins/basecommands.sp Fri Jun 08 01:58:26 2007 +0000
3.3 @@ -42,6 +42,116 @@
3.4 RegAdminCmd("sm_rcon", Command_Rcon, ADMFLAG_RCON, "sm_rcon <args>");
3.5 RegAdminCmd("sm_cvar", Command_Cvar, ADMFLAG_CONVARS, "sm_cvar <cvar> [value]");
3.6 RegAdminCmd("sm_execcfg", Command_ExecCfg, ADMFLAG_CONFIG, "sm_execcfg <filename>");
3.7 + RegAdminCmd("sm_who", Command_Who, ADMFLAG_GENERIC, "sm_who [#userid|name]");
3.8 +}
3.9 +
3.10 +#define FLAG_STRINGS 14
3.11 +new String:g_FlagNames[FLAG_STRINGS][20] =
3.12 +{
3.13 + "reservation",
3.14 + "admin",
3.15 + "kick",
3.16 + "ban",
3.17 + "unban",
3.18 + "slay",
3.19 + "map",
3.20 + "cvars",
3.21 + "cfg",
3.22 + "chat",
3.23 + "vote",
3.24 + "pass",
3.25 + "rcon",
3.26 + "cheat"
3.27 +};
3.28 +
3.29 +FlagsToString(String:buffer[], maxlength, flags)
3.30 +{
3.31 + new String:joins[FLAG_STRINGS][20];
3.32 + new total;
3.33 +
3.34 + for (new i=0; i<FLAG_STRINGS; i++)
3.35 + {
3.36 + if (flags & (1<<i))
3.37 + {
3.38 + strcopy(joins[total++], 20, g_FlagNames[i]);
3.39 + }
3.40 + }
3.41 +
3.42 + ImplodeStrings(joins, total, ", ", buffer, maxlength);
3.43 +}
3.44 +
3.45 +public Action:Command_Who(client, args)
3.46 +{
3.47 + if (args < 1)
3.48 + {
3.49 + /* Display header */
3.50 + new String:t_access[16], String:t_name[16];
3.51 + Format(t_access, sizeof(t_access), "%t", "Access", client);
3.52 + Format(t_name, sizeof(t_name), "%t", "Name", client);
3.53 +
3.54 + PrintToConsole(client, "%-24.23s %s", t_name, t_access);
3.55 +
3.56 + /* List all players */
3.57 + new maxClients = GetMaxClients();
3.58 + new String:flagstring[255];
3.59 +
3.60 + for (new i=1; i<=maxClients; i++)
3.61 + {
3.62 + if (!IsClientInGame(i))
3.63 + {
3.64 + continue;
3.65 + }
3.66 + new flags = GetUserFlagBits(i);
3.67 + if (flags == 0)
3.68 + {
3.69 + strcopy(flagstring, sizeof(flagstring), "none");
3.70 + } else if (flags & ADMFLAG_ROOT) {
3.71 + strcopy(flagstring, sizeof(flagstring), "root");
3.72 + } else {
3.73 + FlagsToString(flagstring, sizeof(flagstring), flags);
3.74 + }
3.75 + decl String:name[65];
3.76 + GetClientName(i, name, sizeof(name));
3.77 + PrintToConsole(client, "%d. %-24.23s %s", i, name, flagstring);
3.78 + }
3.79 +
3.80 + if (GetCmdReplySource() == SM_REPLY_TO_CHAT)
3.81 + {
3.82 + ReplyToCommand(client, "[SM] %t", "See console for output");
3.83 + }
3.84 +
3.85 + return Plugin_Handled;
3.86 + }
3.87 +
3.88 + new String:arg[65];
3.89 + GetCmdArg(1, arg, sizeof(arg));
3.90 +
3.91 + new clients[2];
3.92 + new numClients = SearchForClients(arg, clients, 2);
3.93 +
3.94 + if (numClients == 0)
3.95 + {
3.96 + ReplyToCommand(client, "[SM] %t", "No matching client");
3.97 + return Plugin_Handled;
3.98 + } else if (numClients > 1) {
3.99 + ReplyToCommand(client, "[SM] %t", "More than one client matches", arg);
3.100 + return Plugin_Handled;
3.101 + }
3.102 +
3.103 + new flags = GetUserFlagBits(clients[0]);
3.104 + new String:flagstring[255];
3.105 + if (flags == 0)
3.106 + {
3.107 + strcopy(flagstring, sizeof(flagstring), "none");
3.108 + } else if (flags & ADMFLAG_ROOT) {
3.109 + strcopy(flagstring, sizeof(flagstring), "root");
3.110 + } else {
3.111 + FlagsToString(flagstring, sizeof(flagstring), flags);
3.112 + }
3.113 +
3.114 + ReplyToCommand(client, "[SM] %t: %s", "Access", flagstring);
3.115 +
3.116 + return Plugin_Handled;
3.117 }
3.118
3.119 public Action:Command_ExecCfg(client, args)
4.1 --- a/plugins/include/console.inc Fri Jun 08 01:09:17 2007 +0000
4.2 +++ b/plugins/include/console.inc Fri Jun 08 01:58:26 2007 +0000
4.3 @@ -36,6 +36,15 @@
4.4 };
4.5
4.6 /**
4.7 + * Reply sources for commands.
4.8 + */
4.9 +enum ReplySource
4.10 +{
4.11 + SM_REPLY_TO_CONSOLE = 0,
4.12 + SM_REPLY_TO_CHAT = 1,
4.13 +};
4.14 +
4.15 +/**
4.16 * Console variable query result values.
4.17 */
4.18 enum ConVarQueryResult
4.19 @@ -168,6 +177,13 @@
4.20 native ReplyToCommand(client, const String:format[], any:...);
4.21
4.22 /**
4.23 + * Returns the current reply source of a command.
4.24 + *
4.25 + * @return ReplySource value.
4.26 + */
4.27 +native ReplySource:GetCmdReplySource();
4.28 +
4.29 +/**
4.30 * Displays usage of an admin command to users depending on the
4.31 * setting of the sm_show_activity cvar.
4.32 *
5.1 --- a/translations/common.cfg Fri Jun 08 01:09:17 2007 +0000
5.2 +++ b/translations/common.cfg Fri Jun 08 01:58:26 2007 +0000
5.3 @@ -39,4 +39,19 @@
5.4 {
5.5 "en" "You cannot target this player."
5.6 }
5.7 +
5.8 + "Name"
5.9 + {
5.10 + "en" "Name"
5.11 + }
5.12 +
5.13 + "Access"
5.14 + {
5.15 + "en" "Access"
5.16 + }
5.17 +
5.18 + "See console for output"
5.19 + {
5.20 + "en" "See console for output."
5.21 + }
5.22 }