/admins command help
#8

Well I assumed he was wanting a line-by-line output, as he wasn't very clear about what he wanted in his original post.

With that being said, hopefully this will work:
Without Comments:
pawn Code:
CMD:admins(playerid, params[])
{
    new fstr[130], str[30], count = 0;
    SendClientMessage(playerid, 0x9BBDDEAA, "Present Staff Members:");
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(!IsPlayerConnected(i)) continue;
        if(pInfo[i][pAdmin] < 1) continue;
        count++;
        new name[MAX_PLAYER_NAME];
        GetPlayerName(i, name, sizeof(name));
        format(str, sizeof(str), "%s(%d)", name, i);
        if(((count - 1) % 4) != 0) strins(str, ", ", 0);
        strcat(fstr, str);
        if(count % 4 == 0)
        {
            SendClientMessage(playerid, 0x9BBDDEAA, fstr);
            format(fstr, sizeof(fstr), "");
        }
        if(i == (MAX_PLAYERS - 1))
        {
            if(strlen(fstr)) SendClientMessage(playerid, 0x9BBDDEAA, fstr);
        }
    }
    if(count == 0) return SendClientMessage(playerid,0x9BBDDEAA,"No Admins online");
    return 1;
}
With Comments:
pawn Code:
CMD:admins(playerid, params[]) //When a player types the command '/admins'.
{
    new fstr[130], str[30], count = 0; //Create our full string, temporary string and admin count variables.
    SendClientMessage(playerid, 0x9BBDDEAA, "Present Staff Members:"); //Send the 'Present Staff Members' message.
    for(new i = 0; i < MAX_PLAYERS; i++) //Start a loop through all player ids.
    {
        if(!IsPlayerConnected(i)) continue; //If the player with the ID isn't connected, skip it and do the next one.
        if(pInfo[i][pAdmin] < 1) continue; //If the player is not an admin, skip them and do the next player.
        count++; //We have found an admin, so increase the count by 1.
        new name[MAX_PLAYER_NAME]; //Create a variable to store the admin's name in.
        GetPlayerName(i, name, sizeof(name)); //Get the admin's name, and store it.
        format(str, sizeof(str), "%s(%d)", name, i); //This is what we will see for each admin, their name and their id.
        if(((count - 1) % 4) != 0) strins(str, ", ", 0); //If we are not starting a new line yet, insert ', ' into the string, to separate the admin names.
        strcat(fstr, str); //Insert the temporary string, into the full string.
        if(count % 4 == 0) //If we have reached 4 admins on one line...
        {
            SendClientMessage(playerid, 0x9BBDDEAA, fstr); //Send the full string
            format(fstr, sizeof(fstr), ""); //Empty the full string, so we can continue on another line.
        }
        if(i == (MAX_PLAYERS - 1)) //If we've reached the end of the loop, but we haven't reached a full line...
        {
            if(strlen(fstr)) SendClientMessage(playerid, 0x9BBDDEAA, fstr); //Send the remaining admin names if the string isn't empty.
        }
    }
    if(count == 0) return SendClientMessage(playerid,0x9BBDDEAA,"No Admins online"); //If there were no admins found, return the 'No Admins Online' message.
    return 1;
}
Reply


Messages In This Thread
/admins command help - by ZBits - 23.12.2013, 08:27
Re: /admins command help - by park4bmx - 23.12.2013, 09:11
Re: /admins command help - by Threshold - 23.12.2013, 15:06
Re: /admins command help - by ZBits - 23.12.2013, 20:21
Re: /admins command help - by ZBits - 23.12.2013, 20:26
Re: /admins command help - by mamorunl - 23.12.2013, 23:56
Re: /admins command help - by ZBits - 24.12.2013, 00:38
Re: /admins command help - by Threshold - 24.12.2013, 02:32
Re: /admins command help - by mamorunl - 24.12.2013, 14:12
Re: /admins command help - by ZBits - 24.12.2013, 20:22

Forum Jump:


Users browsing this thread: 2 Guest(s)