plugins/basecommands/who.sp
changeset 1633 8340d8cfb8db
parent 1627 de86e6e12204
child 1789 55172f6df9a4
     1.1 --- a/plugins/basecommands/who.sp	Mon Oct 22 06:01:07 2007 +0000
     1.2 +++ b/plugins/basecommands/who.sp	Mon Oct 22 06:23:58 2007 +0000
     1.3 @@ -1,5 +1,5 @@
     1.4  
     1.5 -PerformWho(client, target, ReplySource:reply)
     1.6 +PerformWho(client, target, ReplySource:reply, bool:is_admin)
     1.7  {
     1.8  	decl String:name[MAX_NAME_LENGTH];
     1.9  	GetClientName(target, name, sizeof(name));
    1.10 @@ -20,28 +20,35 @@
    1.11  	}
    1.12  	else
    1.13  	{
    1.14 -		new flags = GetUserFlagBits(target);
    1.15 -		decl String:flagstring[255];
    1.16 -		if (flags == 0)
    1.17 +		if (!is_admin)
    1.18  		{
    1.19 -			strcopy(flagstring, sizeof(flagstring), "none");
    1.20 -		}
    1.21 -		else if (flags & ADMFLAG_ROOT)
    1.22 -		{
    1.23 -			strcopy(flagstring, sizeof(flagstring), "root");
    1.24 +			ReplyToCommand(client, "[SM] %t", "Player is an admin", name);
    1.25  		}
    1.26  		else
    1.27  		{
    1.28 -			FlagsToString(flagstring, sizeof(flagstring), flags);
    1.29 -		}
    1.30 -		
    1.31 -		if (show_name)
    1.32 -		{
    1.33 -			ReplyToCommand(client, "[SM] %t", "Admin logged in as", name, admin_name, flagstring);
    1.34 -		}
    1.35 -		else
    1.36 -		{
    1.37 -			ReplyToCommand(client, "[SM] %t", "Admin logged in anon", name, flagstring);
    1.38 +			new flags = GetUserFlagBits(target);
    1.39 +			decl String:flagstring[255];
    1.40 +			if (flags == 0)
    1.41 +			{
    1.42 +				strcopy(flagstring, sizeof(flagstring), "none");
    1.43 +			}
    1.44 +			else if (flags & ADMFLAG_ROOT)
    1.45 +			{
    1.46 +				strcopy(flagstring, sizeof(flagstring), "root");
    1.47 +			}
    1.48 +			else
    1.49 +			{
    1.50 +				FlagsToString(flagstring, sizeof(flagstring), flags);
    1.51 +			}
    1.52 +			
    1.53 +			if (show_name)
    1.54 +			{
    1.55 +				ReplyToCommand(client, "[SM] %t", "Admin logged in as", name, admin_name, flagstring);
    1.56 +			}
    1.57 +			else
    1.58 +			{
    1.59 +				ReplyToCommand(client, "[SM] %t", "Admin logged in anon", name, flagstring);
    1.60 +			}
    1.61  		}
    1.62  	}
    1.63  	
    1.64 @@ -110,7 +117,7 @@
    1.65  		}
    1.66  		else
    1.67  		{
    1.68 -			PerformWho(param1, target, SM_REPLY_TO_CHAT);
    1.69 +			PerformWho(param1, target, SM_REPLY_TO_CHAT, (GetUserFlagBits(param1) != 0 ? true : false));
    1.70  		}
    1.71  		
    1.72  		/* Re-draw the menu if they're still valid */
    1.73 @@ -125,15 +132,29 @@
    1.74  }
    1.75  public Action:Command_Who(client, args)
    1.76  {
    1.77 +	new bool:is_admin = false;
    1.78 +	
    1.79 +	if (client && GetUserFlagBits(client) != 0)
    1.80 +	{
    1.81 +		is_admin = true;
    1.82 +	}
    1.83 +	
    1.84  	if (args < 1)
    1.85  	{
    1.86  		/* Display header */
    1.87  		decl String:t_access[16], String:t_name[16], String:t_username[16];
    1.88 -		Format(t_access, sizeof(t_access), "%t", "Access", client);
    1.89 +		Format(t_access, sizeof(t_access), "%t", "Admin access", client);
    1.90  		Format(t_name, sizeof(t_name), "%t", "Name", client);
    1.91  		Format(t_username, sizeof(t_username), "%t", "Username", client);
    1.92  
    1.93 -		PrintToConsole(client, "    %-24.23s %-18.17s %s", t_name, t_username, t_access);
    1.94 +		if (is_admin)
    1.95 +		{
    1.96 +			PrintToConsole(client, "    %-24.23s %-18.17s %s", t_name, t_username, t_access);
    1.97 +		}
    1.98 +		else
    1.99 +		{
   1.100 +			PrintToConsole(client, "    %-24.23s %s", t_name, t_access);
   1.101 +		}
   1.102  
   1.103  		/* List all players */
   1.104  		new maxClients = GetMaxClients();
   1.105 @@ -169,7 +190,21 @@
   1.106  				GetAdminUsername(id, username, sizeof(username));
   1.107  			}
   1.108  			
   1.109 -			PrintToConsole(client, "%2d. %-24.23s %-18.17s %s", i, name, username, flagstring);
   1.110 +			if (is_admin)
   1.111 +			{
   1.112 +				PrintToConsole(client, "%2d. %-24.23s %-18.17s %s", i, name, username, flagstring);
   1.113 +			}
   1.114 +			else
   1.115 +			{
   1.116 +				if (flags == 0)
   1.117 +				{
   1.118 +					PrintToConsole(client, "%2d. %-24.23s %t", i, name, "No");
   1.119 +				}
   1.120 +				else
   1.121 +				{
   1.122 +					PrintToConsole(client, "%2d. %-24.23s %t", i, name, "Yes");
   1.123 +				}
   1.124 +			}
   1.125  		}
   1.126  
   1.127  		if (GetCmdReplySource() == SM_REPLY_TO_CHAT)
   1.128 @@ -183,13 +218,13 @@
   1.129  	decl String:arg[65];
   1.130  	GetCmdArg(1, arg, sizeof(arg));
   1.131  
   1.132 -	new target = FindTarget(client, arg);
   1.133 +	new target = FindTarget(client, arg, false, false);
   1.134  	if (target == -1)
   1.135  	{
   1.136  		return Plugin_Handled;
   1.137  	}
   1.138  	
   1.139 -	PerformWho(client, target, GetCmdReplySource());
   1.140 +	PerformWho(client, target, GetCmdReplySource(), is_admin);
   1.141  
   1.142  	return Plugin_Handled;
   1.143  }