Quote:
Originally Posted by RealCop228
pawn Код:
CMD:admins(playerid, params[]) { new Count; new str[45], Admin[MAX_PLAYER_NAME]; for(new i = 0; i <MAX_PLAYERS; i++) { if (APlayerData[i][PlayerLevel] >= 1) // replace with ur variable { Count++; GetPlayerName(i, Admin, MAX_PLAYER_NAME); SendClientMessage(playerid, -1, "Current Administrators Online"); if(!IsOnAdminDuty[i]) format(str, sizeof(str), "Level %d - %s - Off Admin Duty", APlayerData[i][PlayerLevel], Admin); else if(IsOnAdminDuty[i]) format(str, sizeof(str), "Level %d - %s - On Admin Duty", APlayerData[i][PlayerLevel], Admin); SendClientMessage(playerid, -1, str); } } if(Count < 1) SendClientMessage(playerid, -1, "No Administrators Online!"); return 1; }
So many ways you could save lines. That should work for you, if all of the other variables are correct.
|
I suppose you want
"Current Administrators Online" to only be sent once
above the loop. Furthermore I suggest to use
foreach, which is faster, instead of your loop.
Код:
CMD:admins(playerid, params[])
{
new
Count,
str[45],
Admin[MAX_PLAYER_NAME]
;
SendClientMessage(playerid, -1, "Current Administrators Online:");
foreach (new i : Player)
{
if (APlayerData[i][PlayerLevel] >= 1) // replace with ur variable
{
Count++;
GetPlayerName(i, Admin, MAX_PLAYER_NAME);
format(str, sizeof(str), "Level %d - %s - %s, APlayerData[i][PlayerLevel], Admin, IsOnAdminDuty[i] ? ("On Admin Duty") : ("Off Admin Duty"));
SendClientMessage(playerid, -1, str);
}
}
if(Count < 1) SendClientMessage(playerid, -1, "No Administrators Online!");
return 1;
}