26.09.2012, 22:18
This command will only detect users who are logged into remote console. You can change it to detect users and the admin level variable.
Refer to:
Loops
Format
IsPlayerNPC
IsPlayerAdmin
SendClientMessage
The command also uses zeex's ZCMD command processing include and ******'s foreach include.
ZCMD
Foreach
pawn Код:
CMD:admins(playerid, params[])
{
SendClientMessage(playerid, -1, "______________________________________________________"); // Simply for aesthetics.
new acount = 0, string[100], pName[MAX_PLAYER_NAME]; // New variables are created.
foreach(Player, i) // Looping through users.
{
if(!IsPlayerNPC(i) && IsPlayerAdmin(i)) // Foreach doesn't loop through users if they aren't connected. Added a check to ensure they aren't NPC's along with checking if they are logged into RCON.
{
acount += 1; // Increase the count of the variable everytime an administrator is found online.
GetPlayerName(i, pName, sizeof(pName)); // Get the administrator's name, storing it into the variable. (pName).
format(string, sizeof(string), "Administrator - %s.", pName); // Format the string with the administrator's name which is in the variable. (pName).
SendClientMessage(playerid, -1, string); // Send the user the message we formatted above.
}
}
if(acount == 0) SendClientMessage(playerid, -1, "No server administrators are currently online."); // If the variable is found at zero at the end of the loop, no administrators are logged into RCON or online.
SendClientMessage(playerid, -1, "______________________________________________________"); // Simply for aesthetics.
return 1;
}
Loops
Format
IsPlayerNPC
IsPlayerAdmin
SendClientMessage
The command also uses zeex's ZCMD command processing include and ******'s foreach include.
ZCMD
Foreach