[Tutorial] Making a mute system
#3

Quote:
Originally Posted by DanishHaq
View Post
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...
Reply


Messages In This Thread
Making a mute system - by DanishHaq - 25.09.2013, 19:23
Re: Making a mute system - by BoU3A - 25.09.2013, 23:06
Re: Making a mute system - by WLSF - 25.09.2013, 23:13
Re: Making a mute system - by Voxel - 26.09.2013, 07:06
Re: Making a mute system - by DanishHaq - 26.09.2013, 07:14
Re: Making a mute system - by iZN - 26.09.2013, 08:52
Re: Making a mute system - by x96664 - 26.09.2013, 08:54
Re: Making a mute system - by DanishHaq - 26.09.2013, 22:14
Re : Making a mute system - by Matnix - 27.09.2013, 01:32
Re: Re : Making a mute system - by DanishHaq - 27.09.2013, 06:37

Forum Jump:


Users browsing this thread: 1 Guest(s)