SA-MP Forums Archive
/mute Command - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: /mute Command (/showthread.php?tid=397788)



/mute Command - MikeMike1997 - 06.12.2012

Hey, I need to add so I can set a timer to my mute command. Could I have some help please?

Code:
if(strcmp("/mute", cmd, true) == 0)
        {
                new tmp[256], tmp2[256], cmdid;

                tmp = strtok(cmdtext, idx);
                tmp2 = strtok(cmdtext, idx);
                if(PlayerInfo[playerid][AdminLevel] < 1) return 0;
                if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_RED, "/mute [id] [reason]");
                                  if(IsPlayerConnected(strval(tmp)) == 0) return SendClientMessage(playerid, COLOR_RED, "That player is not connected");
                if(!strlen(tmp2)) return SendClientMessage(playerid, COLOR_RED, "/mute [id] [reason]");
                cmdid = strval(tmp);
      if(PlayerInfo[cmdid][AdminLevel] > PlayerInfo[playerid][AdminLevel]) return SendClientMessage(playerid,COLOR_ORED,"You cant use this command against a higher level admin!");
                new pname[MAX_PLAYER_NAME];
                GetPlayerName(playerid, pname, sizeof(pname));

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

                new string[256];

                if(cmdid >= 0 && cmdid <= 9)
                {
                        format(string, sizeof(string), "~ %s has been muted for '%s' ", oname, cmdtext[7]);
                }
                else if(cmdid >= 10 && cmdid <= 99)
                {
                        format(string, sizeof(string), "~ %s has been muted for '%s' ", oname, cmdtext[8]);

			   }
                else if(cmdid >= 100 && cmdid <= 150)
                {
                        format(string, sizeof(string), "~ %s has been muted for '%s' ", oname, cmdtext[9]);
			    }

                SendClientMessageToAll(COLOR_YELLOW, string);
				muted[cmdid] = 1;
                printf(string);
                return 1;
        }



Re: /mute Command - LarzI - 06.12.2012

https://sampforum.blast.hk/showthread.php?tid=55261 - Read this.

---

Now to your problem.
Simply use SetTimerEx:

pawn Code:
SetTimerEx("muteTimer", 60*1000, false, "i", playerid); //60*1000 = 1 minute
Then make your timer callback:

pawn Code:
forward muteTimer(playerid);
public muteTimer(playerid)
{
    muted[playerid] = 0;
    return SendClientMessage(playerid, 0x00FF0000, "You are no longer muted.");
}



Re: /mute Command - MikeMike1997 - 06.12.2012

What I want tho is /mute id reason time, So you can choose your own time


Re: /mute Command - Konstantinos - 06.12.2012

pawn Code:
// command
// Usage: /mute id reason time
// on command's part
SetTimerEx("muteTimer", 60*1000*time, false, "i", playerid);
// Note; you need to give a value to minutes, so it's 1 minute * time;



Re: /mute Command - MikeMike1997 - 06.12.2012

That does not add to me question tho?


Re: /mute Command - LarzI - 06.12.2012

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!");
}



Re: /mute Command - MikeMike1997 - 07.12.2012

Yes but its not in ZCMD, So I need it in STRCMP. I will convert it when I found someone to do it for me because I simply can't be bothered.