2007-10-13 06:43:42 +02:00
|
|
|
|
|
|
|
PerformWho(client, target, ReplySource:reply)
|
|
|
|
{
|
|
|
|
new flags = GetUserFlagBits(target);
|
|
|
|
decl String:flagstring[255];
|
|
|
|
if (flags == 0)
|
|
|
|
{
|
|
|
|
strcopy(flagstring, sizeof(flagstring), "none");
|
2007-10-19 07:45:56 +02:00
|
|
|
}
|
|
|
|
else if (flags & ADMFLAG_ROOT)
|
|
|
|
{
|
2007-10-13 06:43:42 +02:00
|
|
|
strcopy(flagstring, sizeof(flagstring), "root");
|
2007-10-19 07:45:56 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-10-13 06:43:42 +02:00
|
|
|
FlagsToString(flagstring, sizeof(flagstring), flags);
|
|
|
|
}
|
2007-10-19 07:45:56 +02:00
|
|
|
|
|
|
|
decl String:name[MAX_NAME_LENGTH];
|
|
|
|
GetClientName(client, name, sizeof(name));
|
|
|
|
|
|
|
|
new bool:show_name = false;
|
|
|
|
new String:admin_name[MAX_NAME_LENGTH];
|
|
|
|
new AdminId:id = GetUserAdmin(client);
|
|
|
|
if (id != INVALID_ADMIN_ID && GetAdminUsername(id, admin_name, sizeof(admin_name)))
|
|
|
|
{
|
|
|
|
show_name = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
new ReplySource:old_reply = SetCmdReplySource(reply);
|
|
|
|
|
|
|
|
if (show_name)
|
|
|
|
{
|
|
|
|
ReplyToCommand(client, "[SM] %t", "Admin logged in as", name, admin_name, flagstring);
|
|
|
|
}
|
2007-10-13 06:43:42 +02:00
|
|
|
else
|
2007-10-19 07:45:56 +02:00
|
|
|
{
|
|
|
|
ReplyToCommand(client, "[SM] %t", "Admin logged in anon", name, flagstring);
|
|
|
|
}
|
|
|
|
|
|
|
|
SetCmdReplySource(old_reply);
|
2007-10-13 06:43:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
DisplayWhoMenu(client)
|
|
|
|
{
|
|
|
|
new Handle:menu = CreateMenu(MenuHandler_Who);
|
|
|
|
|
|
|
|
decl String:title[100];
|
2007-10-16 20:37:24 +02:00
|
|
|
Format(title, sizeof(title), "%T:", "Identify player", client);
|
2007-10-13 06:43:42 +02:00
|
|
|
SetMenuTitle(menu, title);
|
|
|
|
SetMenuExitBackButton(menu, true);
|
|
|
|
|
|
|
|
AddTargetsToMenu(menu, client, false);
|
|
|
|
|
|
|
|
DisplayMenu(menu, client, MENU_TIME_FOREVER);
|
|
|
|
}
|
|
|
|
|
|
|
|
public AdminMenu_Who(Handle:topmenu,
|
|
|
|
TopMenuAction:action,
|
|
|
|
TopMenuObject:object_id,
|
|
|
|
param,
|
|
|
|
String:buffer[],
|
|
|
|
maxlength)
|
|
|
|
{
|
|
|
|
if (action == TopMenuAction_DisplayOption)
|
|
|
|
{
|
2007-10-16 20:37:24 +02:00
|
|
|
Format(buffer, maxlength, "%T", "Identify player", param);
|
2007-10-13 06:43:42 +02:00
|
|
|
}
|
|
|
|
else if (action == TopMenuAction_SelectOption)
|
|
|
|
{
|
|
|
|
DisplayWhoMenu(param);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public MenuHandler_Who(Handle:menu, MenuAction:action, param1, param2)
|
|
|
|
{
|
|
|
|
if (action == MenuAction_End)
|
|
|
|
{
|
|
|
|
CloseHandle(menu);
|
|
|
|
}
|
|
|
|
else if (action == MenuAction_Cancel)
|
|
|
|
{
|
|
|
|
if (param2 == MenuCancel_ExitBack && hTopMenu != INVALID_HANDLE)
|
|
|
|
{
|
|
|
|
DisplayTopMenu(hTopMenu, param1, TopMenuPosition_LastCategory);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (action == MenuAction_Select)
|
|
|
|
{
|
|
|
|
decl String:info[32];
|
|
|
|
new userid, target;
|
|
|
|
|
|
|
|
GetMenuItem(menu, param2, info, sizeof(info));
|
|
|
|
userid = StringToInt(info);
|
|
|
|
|
|
|
|
if ((target = GetClientOfUserId(userid)) == 0)
|
|
|
|
{
|
|
|
|
PrintToChat(param1, "[SM] %t", "Player no longer available");
|
|
|
|
}
|
|
|
|
else if (!CanUserTarget(param1, target))
|
|
|
|
{
|
|
|
|
PrintToChat(param1, "[SM] %t", "Unable to target");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
PerformWho(param1, target, SM_REPLY_TO_CHAT);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Re-draw the menu if they're still valid */
|
|
|
|
|
|
|
|
/* - Close the menu? redisplay? jump back up to the category?
|
|
|
|
if (IsClientInGame(param1) && !IsClientInKickQueue(param1))
|
|
|
|
{
|
|
|
|
DisplayWhoMenu(param1);
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
}
|
|
|
|
public Action:Command_Who(client, args)
|
|
|
|
{
|
|
|
|
if (args < 1)
|
|
|
|
{
|
|
|
|
/* Display header */
|
|
|
|
decl 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();
|
|
|
|
decl 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");
|
2007-10-19 07:45:56 +02:00
|
|
|
}
|
|
|
|
else if (flags & ADMFLAG_ROOT)
|
|
|
|
{
|
2007-10-13 06:43:42 +02:00
|
|
|
strcopy(flagstring, sizeof(flagstring), "root");
|
2007-10-19 07:45:56 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-10-13 06:43:42 +02:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
decl 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;
|
2007-10-19 07:45:56 +02:00
|
|
|
}
|
|
|
|
else if (numClients > 1)
|
|
|
|
{
|
2007-10-13 06:43:42 +02:00
|
|
|
ReplyToCommand(client, "[SM] %t", "More than one client matches", arg);
|
|
|
|
return Plugin_Handled;
|
|
|
|
}
|
|
|
|
|
|
|
|
PerformWho(client, clients[0], GetCmdReplySource());
|
|
|
|
|
|
|
|
return Plugin_Handled;
|
|
|
|
}
|