/mute Command
#6

I recommend switching to ZCMD + SScanF2 for 100 times easier commands.

Here's how the code would look:

pawn Code:
CMD:mute(playerid, params[])
{
    new
        cmdid,
        reason[80],
        minutes,
        string[128];

    if(PlayerInfo[playerid][AdminLevel] < 1)
        return 0;
   
    if(sscanf(params, "uis[80]", cmdid, minutes, reason))
        return SendClientMessage(playerid,0xFFFF0000,"Usage: /mute [id/name] [time] [reason]");
    if(PlayerInfo[cmdid][AdminLevel] > PlayerInfo[playerid][AdminLevel])
        return SendClientMessage(playerid,COLOR_ORED,"You cant use this command against a higher level admin!");
    if(cmdid == playerid)
        return SendClientMessage(playerid,COLOR_ORED,"You cant mute yourself!");
    if(!IsPlayerConnected(cmdid) || cmdid == INVALID_PLAYER_ID)
        return SendClientMessage(playerid,COLOR_ORED,"Player not found!");

    new oname[MAX_PLAYER_NAME];
    GetPlayerName(cmdid, oname, sizeof(oname));

    if(time == 0) //permanent mute
    {
        format(string, sizeof(string), "~ %s has been muted. Reason: '%s' ", oname, minutes, reason);
        muted[cmdid] = 1;
    }
    else
    {
        format(string, sizeof(string), "~ %s has been muted for %i minutes. Reason: '%s' ", oname, minutes, reason);
        muted[cmdid] = 1;
        SetTimerEx("unmuteTimer", 60*1000*minutes, false, "i", cmdid);
    }
    SendClientMessageToAll(COLOR_YELLOW, string);
    print(string);
    return 1;
}
And here's the timer function:

pawn Code:
forward muteTimer(playerid);
public unmuteTimer(playerid)
{
    muted[playerid] = 0;
    return SendClientMessage(playerid,0x00FF0000,"You're no longer muted!");
}
Reply


Messages In This Thread
/mute Command - by MikeMike1997 - 06.12.2012, 19:33
Re: /mute Command - by LarzI - 06.12.2012, 19:39
Re: /mute Command - by MikeMike1997 - 06.12.2012, 19:47
Re: /mute Command - by Konstantinos - 06.12.2012, 19:49
Re: /mute Command - by MikeMike1997 - 06.12.2012, 20:54
Re: /mute Command - by LarzI - 06.12.2012, 21:27
Re: /mute Command - by MikeMike1997 - 07.12.2012, 14:46

Forum Jump:


Users browsing this thread: 1 Guest(s)