To make an /admins command, you will need to loop through all online players. This can be achieved by using a typical for-loop, a while-loop or in terms of easier approach, foreach by ****** will help you do this quite efficiently as well.
Then you will simply need to see if the player's level is not zero (meaning the player is an admin).
pawn Код:
for(new i = 0; i != MAX_PLAYERS; i++)
{
if(PlayerInfo[i][pAdmin])
{
// Send message?
}
}
(Note this loop would require you to reset the pAdmin variable in OnPlayerDisconnect as no connection check is involved here - I consider this variable check to already be considered a connection check)
Note that more sophisticated methods are available here. If you were to run a large server and had a large staff team and an /admins command on the server, in some cases, there would be more staff members online than lines to display (although this can be expanded up to 20 lines). Then you could use some clever string concatenation (strcat) and formatting to put not just one, but two or three admin names on one line.
The second question has a simple answer: what you're trying to do is put the return value of GetPlayerName into the string using the %s specifier. This will not give you the result you desire. To have a numeric representation of the return value of GetPlayerName, you'd need to use %i or %d.
But then again, that's not what you need, either. You will need to have the GetPlayerName line PRIOR to the format line, and have "aname" as the parameter, not the GetPlayerName function call.
pawn Код:
GetPlayerName(playerid, aname, sizeof(aname));
format(str, sizeof(str), "%s", aname);