added amb1015 part2 - more sm_who changes

--HG--
extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%401614
This commit is contained in:
David Anderson 2007-10-19 06:36:06 +00:00
parent 86dbfbd248
commit 4e1c0edfca
2 changed files with 67 additions and 24 deletions

View File

@ -1,27 +1,12 @@
PerformWho(client, target, ReplySource:reply) PerformWho(client, target, ReplySource:reply)
{ {
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);
}
decl String:name[MAX_NAME_LENGTH]; decl String:name[MAX_NAME_LENGTH];
GetClientName(client, name, sizeof(name)); GetClientName(target, name, sizeof(name));
new bool:show_name = false; new bool:show_name = false;
new String:admin_name[MAX_NAME_LENGTH]; new String:admin_name[MAX_NAME_LENGTH];
new AdminId:id = GetUserAdmin(client); new AdminId:id = GetUserAdmin(target);
if (id != INVALID_ADMIN_ID && GetAdminUsername(id, admin_name, sizeof(admin_name))) if (id != INVALID_ADMIN_ID && GetAdminUsername(id, admin_name, sizeof(admin_name)))
{ {
show_name = true; show_name = true;
@ -29,13 +14,35 @@ PerformWho(client, target, ReplySource:reply)
new ReplySource:old_reply = SetCmdReplySource(reply); new ReplySource:old_reply = SetCmdReplySource(reply);
if (show_name) if (id == INVALID_ADMIN_ID)
{ {
ReplyToCommand(client, "[SM] %t", "Admin logged in as", name, admin_name, flagstring); ReplyToCommand(client, "[SM] %t", "Player is not an admin", name);
} }
else 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);
}
} }
SetCmdReplySource(old_reply); SetCmdReplySource(old_reply);
@ -121,11 +128,12 @@ public Action:Command_Who(client, args)
if (args < 1) if (args < 1)
{ {
/* Display header */ /* Display header */
decl String:t_access[16], String:t_name[16]; 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", "Access", client);
Format(t_name, sizeof(t_name), "%t", "Name", client); Format(t_name, sizeof(t_name), "%t", "Name", client);
Format(t_username, sizeof(t_username), "%t", "Username", client);
PrintToConsole(client, "%-24.23s %s", t_name, t_access); PrintToConsole(client, " %-24.23s %-18.17s %s", t_name, t_username, t_access);
/* List all players */ /* List all players */
new maxClients = GetMaxClients(); new maxClients = GetMaxClients();
@ -138,6 +146,7 @@ public Action:Command_Who(client, args)
continue; continue;
} }
new flags = GetUserFlagBits(i); new flags = GetUserFlagBits(i);
new AdminId:id = GetUserAdmin(i);
if (flags == 0) if (flags == 0)
{ {
strcopy(flagstring, sizeof(flagstring), "none"); strcopy(flagstring, sizeof(flagstring), "none");
@ -150,9 +159,17 @@ public Action:Command_Who(client, args)
{ {
FlagsToString(flagstring, sizeof(flagstring), flags); FlagsToString(flagstring, sizeof(flagstring), flags);
} }
decl String:name[65]; decl String:name[MAX_NAME_LENGTH];
new String:username[MAX_NAME_LENGTH];
GetClientName(i, name, sizeof(name)); GetClientName(i, name, sizeof(name));
PrintToConsole(client, "%d. %-24.23s %s", i, name, flagstring);
if (id != INVALID_ADMIN_ID)
{
GetAdminUsername(id, username, sizeof(username));
}
PrintToConsole(client, "%2d. %-24.23s %-18.17s %s", i, name, username, flagstring);
} }
if (GetCmdReplySource() == SM_REPLY_TO_CHAT) if (GetCmdReplySource() == SM_REPLY_TO_CHAT)

View File

@ -74,16 +74,42 @@
{ {
"en" "Admin cache has been refreshed." "en" "Admin cache has been refreshed."
} }
"Identify player" "Identify player"
{ {
"en" "Identify player" "en" "Identify player"
} }
"Choose Map" "Choose Map"
{ {
"en" "Choose Map" "en" "Choose Map"
} }
"Exec CFG" "Exec CFG"
{ {
"en" "Exec CFG" "en" "Exec CFG"
} }
"Admin logged in as"
{
"#format" "{1:s},{2:s},{3:s}"
"en" "\"{1}\" is logged in as \"{2}\" with access: {3}"
}
"Admin logged in anon"
{
"#format" "{1:s},{2:s}"
"en" "\"{1}\" has access: {2}"
}
"Player is not an admin"
{
"#format" "{1:s}"
"en" "\"{1}\" is not logged in as an admin."
}
"Username"
{
"en" "Username"
}
} }