05.05.2012, 17:41
i want to make a command /admins so tht when we do tht we can see how many admins are online
(No. of admins) Admins are online..
pls help me . +rep
(No. of admins) Admins are online..
pls help me . +rep
CMD:admins(playerid,params[])
{
new Count, string[128],n[MAX_PLAYER_NAME];
SendClientMessage(playerid, blue, "__________|Admins|__________");
foreach(Player, i)
{
if(PInfo[i][Level] >=1) {
new str[128];
GetPlayerName(i,n,sizeof(n));
format(str, 128, "%s", n);
SendClientMessage(playerid, COLOR_WHITE, str);
}
}
if(Count == 0) SendClientMessage(playerid, blue, " Server Level:1337 ");
SendClientMessage(playerid, blue, "____________________________");
return 1;
}
i want to make a command /admins so tht when we do tht we can see how many admins are online
(No. of admins) Admins are online.. pls help me . +rep |
new count; // Initialize a variable for storing the count
for(int i; i < MAX_PLAYERS; i++) // Do a loop which iterates for every playerid
if(IsPlayerAdmin(i)) count++; // Check if that person is an RCON administrator and if so, increment the variable
printf("There are %d administrators online", count); // Print the results
CMD:admins(playerid, params[]) // zcmd
{
new count = 0; // count var
new string[128], pNick[MAX_PLAYER_NAME];
foreach(Player, i) // loop
{
if(YourAdminVar[i] >= 1)
{
GetPlayerName(i, pNick, MAX_PLAYER_NAME);
format(string, sizeof(string), "Admin: %s", pNick);
SendClientMessage(playerid, -1, string);
count++;
}
}
if(count == 0) SendClientMessage(playerid, -1, "No admins online");
return 1;
}
CMD:admins(playerid, params[]) // zcmd
{
new count = 0; // count var
new string[128];
foreach(Player, i) // loop
{
if(YourAdminVar[i] >= 1)
{
count++;
format(string, sizeof(string), "Admins Online: %d", count);
SendClientMessage(playerid, -1, string);
}
}
if(count == 0) SendClientMessage(playerid, -1, "No admins online");
return 1;
}
Simply use a loop to go through all of the players and see which ones are administrators, then increment an integer when one is found and display the result, for example:
pawn Код:
|
SATDM_v11.pwn(9046) : error 017: undefined symbol "int"
SATDM_v11.pwn(9046) : error 017: undefined symbol "i"
SATDM_v11.pwn(9046) : warning 215: expression has no effect
SATDM_v11.pwn(9046) : error 001: expected token: ")", but found ";"
SATDM_v11.pwn(9046) : fatal error 107: too many error messages on one line
errors
pawn Код:
|
new count; // Initialize a variable for storing the count
for(new i; i < MAX_PLAYERS; i++) // Do a loop which iterates for every playerid
if(IsPlayerAdmin(i)) count++; // Check if that person is an RCON administrator and if so, increment the variable
printf("There are %d administrators online", count); // Print the results