23.12.2013, 08:27
(
Last edited by ZBits; 16/08/2014 at 08:29 PM.
)
Fixed
COMMAND:admins(playerid, params[])
{
new AStr[240],FStr[240],CounT=0;
for(new i=0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i) && pInfo[i][pAdmin] >= 1)
{
new name[MAX_PLAYER_NAME];CounT++;
GetPlayerName(i, name, sizeof(name));
format(AStr, sizeof(AStr), "%s(%d)\n",name,i);
strcat(FStr, AStr, sizeof(FStr));
}
}
if(CounT>0){
SendClientMessage(playerid,0x9BBDDEAA,"Present Staff Members:");
SendClientMessage(playerid,0x9BBDDEAA,FStr);
}else SendClientMessage(playerid,0x9BBDDEAA,"No Admins online");
return 1;
}
COMMAND:admins(playerid, params[])
{
new str[30], count = 0;
for(new i=0; i < MAX_PLAYERS; i++)
{
if(!IsPlayerConnected(i)) continue;
if(pInfo[i][pAdmin] < 1) continue;
if(count == 0) SendClientMessage(playerid,0x9BBDDEAA,"Present Staff Members:");
new name[MAX_PLAYER_NAME];
GetPlayerName(i, name, sizeof(name));
format(str, sizeof(str), "%s(%d)", name, i);
SendClientMessage(playerid, 0x9BBDDEAA, str);
count++;
}
if(count == 0) return SendClientMessage(playerid,0x9BBDDEAA,"No Admins online");
return 1;
}
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;
}
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;
}
if(i == (MAX_PLAYERS - 1))
{
if(strlen(fstr)) SendClientMessage(playerid, 0x9BBDDEAA, fstr);
}
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:
pawn Code:
|