How to fix this CMD:
#1

pawn Код:
CMD:mute(playerid, params[])
{
    new string[256];
    if(!IsAdmin(playerid)) return NotAdmin(playerid);
    new muteid, mutetime, reason[256];
    new nameid[20];
    if(sscanf(params, "s[20]I(2)S(No reason)[80]", nameid, mutetime, reason)){
        return SendClientMessage(playerid, COLOR_YELLOW, "Usage: /mute [id] [minutes] [reason]");

    }
    if(ReturnUser(nameid,playerid) == -1)
    {

        return 1;
    } else {

        muteid = ReturnUser(nameid, playerid);
    }
    if(!IsPlayerConnected(muteid)){
        return SendClientMessage(playerid, COLOR_YELLOW, "Player is not connected !");
    }
    new file[256];
    file = GetUserPath(muteid,1);


    if(dini_Int(file,"muted")){

        return SendClientMessage(playerid, COLOR_YELLOW, "Player is already muted !");

    }
   
    mutetime = mutetime * 60;



    format(string, sizeof string, "%s has been muted %i seconds by %s for %s", GetName(muteid), mutetime, GetName(playerid), reason);
    SendClientMessageToAll(COLOR_RED_SHINY, string);

    format(string, sizeof string, "You have been muted %i seconds !", mutetime);
    SendClientMessage(muteid,COLOR_RED_SHINY, string);



    dini_IntSet(file, "mute_t", GetTickCount() + mutetime * 1000);
    dini_IntSet(file, "muted", 1);
    dini_IntSet(file, "mute_s", mutetime * 1000);
   

    return 1;

}
pawn Код:
forward muteTimer();
public muteTimer()
{



 for(new i; i < MAX_PLAYERS; i++)
 {

    if(!IsPlayerConnected(i)) continue;
    new file[256];
    file = GetUserPath(i,1);
    if(dini_Int(file,"muted") && GetTickCount() > dini_Int(file, "mute_t")) {


        dini_IntSet(file, "mute_t", -1);
        dini_IntSet(file, "muted", 0);
       
        SendClientMessage(i,0x006600ff, "You have been automatically unmuted.");

    }




 }
}

mute__connect(playerid)
{
    new file[256];
    file = GetUserPath(playerid,1);
    if(dini_Int(file,"muted"))
    {

        dini_IntSet(file, "mute_t", GetTickCount() + dini_Int(file, "mute_s"));
    }

    return 1;


}

When I mute a player he still can talk.

Thanks Pandita.
Reply
#2

pawn Код:
new IsMuted[MAX_PLAYERS];
<-- on top of your script
pawn Код:
IsMuted[playerid] = 1; // In mute command
pawn Код:
public OnPlayerText(playerid, text)
{
    If(IsMuted[playerid] == 1)
    {
        SendClientMessage(playerid, -1, "You can't speak while muted");
     }
     Return 0;
}
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)