added amb932 - sm_who can be used by normal clients if the server allows it

--HG--
extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%401639
This commit is contained in:
David Anderson 2007-10-22 06:23:58 +00:00
parent 3c460aa48a
commit c6eaccde0b
3 changed files with 76 additions and 26 deletions

View File

@ -5,13 +5,17 @@ Overrides
* 1)Command Name (for example, "csdm_enable")
* 2)Command Group Name (for example, "CSDM")
* 3)Command Level (for example, "changemap")
*
* You can override the default flags assigned to individual commands or command groups in this way.
* To override a group, use the "@" character before the name. Example:
* Examples:
* "@CSDM" "b" // Override the CSDM group to 'b' flag
* "csdm_enable" "bgi" // Override the csdm_enable command to 'bgi' flags
*
* Note that for overrides, order is important. In the above example, csdm_enable overwrites
* any setting that csdm_enable previously had.
*
* You can make a command completely public by using an empty flag string.
*/
}

View File

@ -1,5 +1,5 @@
PerformWho(client, target, ReplySource:reply)
PerformWho(client, target, ReplySource:reply, bool:is_admin)
{
decl String:name[MAX_NAME_LENGTH];
GetClientName(target, name, sizeof(name));
@ -20,28 +20,35 @@ PerformWho(client, target, ReplySource:reply)
}
else
{
new flags = GetUserFlagBits(target);
decl String:flagstring[255];
if (flags == 0)
if (!is_admin)
{
strcopy(flagstring, sizeof(flagstring), "none");
}
else if (flags & ADMFLAG_ROOT)
{
strcopy(flagstring, sizeof(flagstring), "root");
ReplyToCommand(client, "[SM] %t", "Player is an admin", name);
}
else
{
FlagsToString(flagstring, sizeof(flagstring), flags);
}
if (show_name)
{
ReplyToCommand(client, "[SM] %t", "Admin logged in as", name, admin_name, flagstring);
}
else
{
ReplyToCommand(client, "[SM] %t", "Admin logged in anon", name, flagstring);
new flags = GetUserFlagBits(target);
decl 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);
}
if (show_name)
{
ReplyToCommand(client, "[SM] %t", "Admin logged in as", name, admin_name, flagstring);
}
else
{
ReplyToCommand(client, "[SM] %t", "Admin logged in anon", name, flagstring);
}
}
}
@ -110,7 +117,7 @@ public MenuHandler_Who(Handle:menu, MenuAction:action, param1, param2)
}
else
{
PerformWho(param1, target, SM_REPLY_TO_CHAT);
PerformWho(param1, target, SM_REPLY_TO_CHAT, (GetUserFlagBits(param1) != 0 ? true : false));
}
/* Re-draw the menu if they're still valid */
@ -125,15 +132,29 @@ public MenuHandler_Who(Handle:menu, MenuAction:action, param1, param2)
}
public Action:Command_Who(client, args)
{
new bool:is_admin = false;
if (client && GetUserFlagBits(client) != 0)
{
is_admin = true;
}
if (args < 1)
{
/* Display header */
decl String:t_access[16], String:t_name[16], String:t_username[16];
Format(t_access, sizeof(t_access), "%t", "Access", client);
Format(t_access, sizeof(t_access), "%t", "Admin access", client);
Format(t_name, sizeof(t_name), "%t", "Name", client);
Format(t_username, sizeof(t_username), "%t", "Username", client);
PrintToConsole(client, " %-24.23s %-18.17s %s", t_name, t_username, t_access);
if (is_admin)
{
PrintToConsole(client, " %-24.23s %-18.17s %s", t_name, t_username, t_access);
}
else
{
PrintToConsole(client, " %-24.23s %s", t_name, t_access);
}
/* List all players */
new maxClients = GetMaxClients();
@ -169,7 +190,21 @@ public Action:Command_Who(client, args)
GetAdminUsername(id, username, sizeof(username));
}
PrintToConsole(client, "%2d. %-24.23s %-18.17s %s", i, name, username, flagstring);
if (is_admin)
{
PrintToConsole(client, "%2d. %-24.23s %-18.17s %s", i, name, username, flagstring);
}
else
{
if (flags == 0)
{
PrintToConsole(client, "%2d. %-24.23s %t", i, name, "No");
}
else
{
PrintToConsole(client, "%2d. %-24.23s %t", i, name, "Yes");
}
}
}
if (GetCmdReplySource() == SM_REPLY_TO_CHAT)
@ -183,13 +218,13 @@ public Action:Command_Who(client, args)
decl String:arg[65];
GetCmdArg(1, arg, sizeof(arg));
new target = FindTarget(client, arg);
new target = FindTarget(client, arg, false, false);
if (target == -1)
{
return Plugin_Handled;
}
PerformWho(client, target, GetCmdReplySource());
PerformWho(client, target, GetCmdReplySource(), is_admin);
return Plugin_Handled;
}

View File

@ -105,7 +105,13 @@
"Player is not an admin"
{
"#format" "{1:s}"
"en" "\"{1}\" is not logged in as an admin."
"en" "\"{1}\" is not an admin."
}
"Player is an admin"
{
"#format" "{1:s}"
"en" "\"{1}\" is an admin."
}
"Username"
@ -118,4 +124,9 @@
"#format" "{1:t}"
"en" "Kicked {1}."
}
"Admin access"
{
"en" "Admin access"
}
}