- sm_show_activity is now protected
- added sm_who - added GetCmdReplySource() for sm_who --HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%40929
This commit is contained in:
parent
de339cab8b
commit
a5d17bbf6b
@ -706,6 +706,11 @@ static cell_t ReplyToCommand(IPluginContext *pContext, const cell_t *params)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static cell_t GetCmdReplyTarget(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
return g_ChatTriggers.GetReplyTo();
|
||||
}
|
||||
|
||||
REGISTER_NATIVES(consoleNatives)
|
||||
{
|
||||
{"CreateConVar", sm_CreateConVar},
|
||||
@ -741,5 +746,6 @@ REGISTER_NATIVES(consoleNatives)
|
||||
{"ClientCommand", sm_ClientCommand},
|
||||
{"FakeClientCommand", FakeClientCommand},
|
||||
{"ReplyToCommand", ReplyToCommand},
|
||||
{"GetCmdReplySource", GetCmdReplyTarget},
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
@ -19,7 +19,7 @@
|
||||
#include "sourcemod.h"
|
||||
#include <inetchannelinfo.h>
|
||||
|
||||
ConVar sm_show_activity("sm_show_activity", "13", FCVAR_SPONLY, "Activity display setting (see sourcemod.cfg)");
|
||||
ConVar sm_show_activity("sm_show_activity", "13", FCVAR_SPONLY|FCVAR_PROTECTED, "Activity display setting (see sourcemod.cfg)");
|
||||
|
||||
static cell_t sm_GetClientCount(IPluginContext *pCtx, const cell_t *params)
|
||||
{
|
||||
|
@ -42,6 +42,116 @@ public OnPluginStart()
|
||||
RegAdminCmd("sm_rcon", Command_Rcon, ADMFLAG_RCON, "sm_rcon <args>");
|
||||
RegAdminCmd("sm_cvar", Command_Cvar, ADMFLAG_CONVARS, "sm_cvar <cvar> [value]");
|
||||
RegAdminCmd("sm_execcfg", Command_ExecCfg, ADMFLAG_CONFIG, "sm_execcfg <filename>");
|
||||
RegAdminCmd("sm_who", Command_Who, ADMFLAG_GENERIC, "sm_who [#userid|name]");
|
||||
}
|
||||
|
||||
#define FLAG_STRINGS 14
|
||||
new String:g_FlagNames[FLAG_STRINGS][20] =
|
||||
{
|
||||
"reservation",
|
||||
"admin",
|
||||
"kick",
|
||||
"ban",
|
||||
"unban",
|
||||
"slay",
|
||||
"map",
|
||||
"cvars",
|
||||
"cfg",
|
||||
"chat",
|
||||
"vote",
|
||||
"pass",
|
||||
"rcon",
|
||||
"cheat"
|
||||
};
|
||||
|
||||
FlagsToString(String:buffer[], maxlength, flags)
|
||||
{
|
||||
new String:joins[FLAG_STRINGS][20];
|
||||
new total;
|
||||
|
||||
for (new i=0; i<FLAG_STRINGS; i++)
|
||||
{
|
||||
if (flags & (1<<i))
|
||||
{
|
||||
strcopy(joins[total++], 20, g_FlagNames[i]);
|
||||
}
|
||||
}
|
||||
|
||||
ImplodeStrings(joins, total, ", ", buffer, maxlength);
|
||||
}
|
||||
|
||||
public Action:Command_Who(client, args)
|
||||
{
|
||||
if (args < 1)
|
||||
{
|
||||
/* Display header */
|
||||
new String:t_access[16], String:t_name[16];
|
||||
Format(t_access, sizeof(t_access), "%t", "Access", client);
|
||||
Format(t_name, sizeof(t_name), "%t", "Name", client);
|
||||
|
||||
PrintToConsole(client, "%-24.23s %s", t_name, t_access);
|
||||
|
||||
/* List all players */
|
||||
new maxClients = GetMaxClients();
|
||||
new String:flagstring[255];
|
||||
|
||||
for (new i=1; i<=maxClients; i++)
|
||||
{
|
||||
if (!IsClientInGame(i))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
new flags = GetUserFlagBits(i);
|
||||
if (flags == 0)
|
||||
{
|
||||
strcopy(flagstring, sizeof(flagstring), "none");
|
||||
} else if (flags & ADMFLAG_ROOT) {
|
||||
strcopy(flagstring, sizeof(flagstring), "root");
|
||||
} else {
|
||||
FlagsToString(flagstring, sizeof(flagstring), flags);
|
||||
}
|
||||
decl String:name[65];
|
||||
GetClientName(i, name, sizeof(name));
|
||||
PrintToConsole(client, "%d. %-24.23s %s", i, name, flagstring);
|
||||
}
|
||||
|
||||
if (GetCmdReplySource() == SM_REPLY_TO_CHAT)
|
||||
{
|
||||
ReplyToCommand(client, "[SM] %t", "See console for output");
|
||||
}
|
||||
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
new String:arg[65];
|
||||
GetCmdArg(1, arg, sizeof(arg));
|
||||
|
||||
new clients[2];
|
||||
new numClients = SearchForClients(arg, clients, 2);
|
||||
|
||||
if (numClients == 0)
|
||||
{
|
||||
ReplyToCommand(client, "[SM] %t", "No matching client");
|
||||
return Plugin_Handled;
|
||||
} else if (numClients > 1) {
|
||||
ReplyToCommand(client, "[SM] %t", "More than one client matches", arg);
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
new flags = GetUserFlagBits(clients[0]);
|
||||
new String:flagstring[255];
|
||||
if (flags == 0)
|
||||
{
|
||||
strcopy(flagstring, sizeof(flagstring), "none");
|
||||
} else if (flags & ADMFLAG_ROOT) {
|
||||
strcopy(flagstring, sizeof(flagstring), "root");
|
||||
} else {
|
||||
FlagsToString(flagstring, sizeof(flagstring), flags);
|
||||
}
|
||||
|
||||
ReplyToCommand(client, "[SM] %t: %s", "Access", flagstring);
|
||||
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
public Action:Command_ExecCfg(client, args)
|
||||
|
@ -35,6 +35,15 @@ enum QueryCookie
|
||||
QUERYCOOKIE_FAILED = 0,
|
||||
};
|
||||
|
||||
/**
|
||||
* Reply sources for commands.
|
||||
*/
|
||||
enum ReplySource
|
||||
{
|
||||
SM_REPLY_TO_CONSOLE = 0,
|
||||
SM_REPLY_TO_CHAT = 1,
|
||||
};
|
||||
|
||||
/**
|
||||
* Console variable query result values.
|
||||
*/
|
||||
@ -167,6 +176,13 @@ native PrintToConsole(client, const String:format[], any:...);
|
||||
*/
|
||||
native ReplyToCommand(client, const String:format[], any:...);
|
||||
|
||||
/**
|
||||
* Returns the current reply source of a command.
|
||||
*
|
||||
* @return ReplySource value.
|
||||
*/
|
||||
native ReplySource:GetCmdReplySource();
|
||||
|
||||
/**
|
||||
* Displays usage of an admin command to users depending on the
|
||||
* setting of the sm_show_activity cvar.
|
||||
|
@ -39,4 +39,19 @@
|
||||
{
|
||||
"en" "You cannot target this player."
|
||||
}
|
||||
|
||||
"Name"
|
||||
{
|
||||
"en" "Name"
|
||||
}
|
||||
|
||||
"Access"
|
||||
{
|
||||
"en" "Access"
|
||||
}
|
||||
|
||||
"See console for output"
|
||||
{
|
||||
"en" "See console for output."
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user