/mute Command [ZCMD]
#1

Hello guys! How can I create a mute command with zcmd?
Reply
#2

pawn Код:
CMD:mute(playerid,params[])
{
    if(pInfo[playerid][Admin]>=3)
    {
        new plid,minutes,reason[64];
        if(sscanf(params,"uis[64]",plid,minutes,reason)) return SCM(playerid,COLOR_GREY,"INFO: /mute [playerid][minutes][reason]");
        if(!IsPlayerConnected(plid)) return SCM(playerid,COLOR_GREY,"No such player");
        if(minutes<1 || minutes>99999) return SCM(playerid,COLOR_GREY,"You can't mute a player for more than 99999 minutes!");
        new adminname[MAX_PLAYER_NAME],playername[MAX_PLAYER_NAME],string[256];
        GetPlayerName(playerid,adminname,sizeof(adminname));
        GetPlayerName(plid,playername,sizeof(playername));
        format(string,sizeof(string),"[ADMIN] {%06x}%s {FF6347}was muted by {%06x}%s {FF6347}for %d minutes, reason: {33CCFF}%s",GetPlayerColor(plid)>>>8,playername,GetPlayerColor(playerid)>>>8,adminname,minutes,reason);
        SendClientMessageToAll(COLOR_LIGHTRED,string);
        new mtm=minutes*60;
        pInfo[plid][MuteSeconds]=mtm;
    }
    else return SCM(playerid,COLOR_LIGHTRED,"You are not allowed to use this command!");
    return 1;
}
This under OnGameModeInit:
pawn Код:
SetTimer("Timer_ProcessMutes",1000,true);
This somewhere at the beginning of the script:
pawn Код:
forward Timer_ProcessMutes();
And this anywhere in the script (just not inside a callback):
pawn Код:
public Timer_ProcessMutes()
{
    for(new i=0; i<MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            if(Logged[i]==1)
            {
                if(pInfo[i][MuteSeconds]!=0)
                {
                    pInfo[i][MuteSeconds]--;
                }
            }
        }
    }
}
You'll need to change & add some variables in your script like pInfo[i][MuteSeconds] or pInfo[playerid][Admin].
Also, sorry for the indentation, I can't really fix it on the forum. Make sure to fix it when putting it in your GM
Reply
#3

I want it without minutes
Reply
#4

It's not hard... Also, i forgot to add the key piece, in onplayertext, sorry for that :P
Here's the things you need to add (forget about the previous ones ofc)
pawn Код:
CMD:mute(playerid,params[])
{
    if(pInfo[playerid][Admin]>=3)
    {
        new plid,reason[64];
        if(sscanf(params,"us[64]",plid,reason)) return SCM(playerid,COLOR_GREY,"INFO: /mute [playerid][reason]");
        if(!IsPlayerConnected(plid)) return SCM(playerid,COLOR_GREY,"No such player");
        new adminname[MAX_PLAYER_NAME],playername[MAX_PLAYER_NAME],string[256];
        GetPlayerName(playerid,adminname,sizeof(adminname));
        GetPlayerName(plid,playername,sizeof(playername));
        format(string,sizeof(string),"[ADMIN] {%06x}%s {FF6347}was muted by {%06x}%s{FF6347}, reason: {33CCFF}%s",GetPlayerColor(plid)>>>8,playername,GetPlayerColor(playerid)>>>8,adminname,reason);
        SendClientMessageToAll(COLOR_LIGHTRED,string);
        pInfo[plid][Muted]=1;
    }
    else return SCM(playerid,COLOR_LIGHTRED,"You are not allowed to use this command!");
    return 1;
}
And I guess you may need an unmute command, just in case:
pawn Код:
CMD:unmute(playerid,params[])
{
    if(pInfo[playerid][Admin]>=3)
    {
        new plid;
        if(sscanf(params,"u",plid)) return SCM(playerid,COLOR_GREY,"INFO: /unmute [playerid][reason]");
        if(!IsPlayerConnected(plid)) return SCM(playerid,COLOR_GREY,"No such player");
        new adminname[MAX_PLAYER_NAME],playername[MAX_PLAYER_NAME],string[256];
        GetPlayerName(playerid,adminname,sizeof(adminname));
        GetPlayerName(plid,playername,sizeof(playername));
        format(string,sizeof(string),"[ADMIN] {%06x}%s {FF6347}was unmuted by {%06x}%s{FF6347}",GetPlayerColor(plid)>>>8,playername,GetPlayerColor(playerid)>>>8,adminname);
        SendClientMessageToAll(COLOR_LIGHTRED,string);
        pInfo[plid][Muted]=0;
    }
    else return SCM(playerid,COLOR_LIGHTRED,"You are not allowed to use this command!");
    return 1;
}
And this under OnPlayerText callback
pawn Код:
if(pInfo[playerid][Muted]) return SendClientMessage(playerid,COLOR_LIGHTRED,"You can't talk because you're muted!");
Reply
#5

Ok thanks!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)