Pls help me (+rep)
#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
Reply
#2

pawn Код:
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;
}
Reply
#3

Quote:
Originally Posted by Xtreme Brotherz
Посмотреть сообщение
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
https://sampforum.blast.hk/showthread.php?tid=330069

Be on one topic, don't make another when you've made already one.
Reply
#4

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 Код:
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
Now you can edit that to your liking, with your own administrative check if you have one and your own in-game message using SendClientMessage.
Reply
#5

Simple:

pawn Код:
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;
}
Didn't tested but it should work just fine


EDIT: oh didn't noticed the post above
Reply
#6

i dont want the players to see the admins name only the no. of admins
Reply
#7

Use this then.

pawn Код:
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;
}
Reply
#8

thnxx +rep

Quote:
Originally Posted by JaTochNietDan
Посмотреть сообщение
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 Код:
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
Now you can edit that to your liking, with your own administrative check if you have one and your own in-game message using SendClientMessage.
errors
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
Reply
#9

Quote:
Originally Posted by Xtreme Brotherz
Посмотреть сообщение
errors
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
Apologies, that's my Java programming language knowledge leaking into my PAWN knowledge!

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)