Quote:
Originally Posted by DanishHaq
pawn Code:
CMD:mutelist(playerid, params[]) { new iname[MAX_PLAYER_NAME], string[120], count; // new variables for(new i = 0; i < MAX_PLAYERS; i++) // loops all the players { if(IsPlayerConnected(i)) // checks if the player is connected { if(Mute[i] >= 1) // checks if the looped player is muted at the moment { GetPlayerName(i, iname, sizeof(iname)); // if they are, this retrieves the name format(string, sizeof(string), "%s (%d) - %d seconds remaining", iname, i, Mute[i]); // sets the string SendClientMessage(playerid, 0xFFFFFFFF, string); // sends the message count++; // puts the count to a ++ value, you'll see why further down } } } if(count == 0) return SendClientMessage(playerid, 0xFFFFFFFF, "There are no muted players online."); // if there are no muted players online, it'll return this message if(count == 1) return SendClientMessage(playerid, 0xFFFFFFFF, "There is 1 player who is muted online."); // if there's just 1 muted player online, it'll returns this message if(count >= 2) // if there are more than 1 muted players online, the following will occur { format(string, sizeof(string), "There are %d amount of players who are online and muted.", count); // sets the string SendClientMessage(playerid, 0xFFFFFFFF, string); // sends the message } return 1; }
|
You can use switch for this...
pawn Code:
switch(count)
{
case 0:
{
SendClientMessage(playerid, 0xFFFFFFFF, "There are no muted players online."); // if there are no muted players online, it'll return this message
return 1;
}
case 1:
{
SendClientMessage(playerid, 0xFFFFFFFF, "There is 1 player who is muted online."); // if there's just 1 muted player online, it'll returns this message
return 1;
}
default:
{
format(string, sizeof(string), "There are %d amount of players who are online and muted.", count); // sets the string
SendClientMessage(playerid, 0xFFFFFFFF, string); // sends the message
return 1;
}
}
Good job, +rep.
edit: You have given out too much Reputation in the last 24 hours, try again later.
errm...