How to make player get unmuted after the timer?
#1

My problem is that when player gets muted for 1 min (or more), when the minute pass he doesn't gets unmuted. this is my code

pawn Код:
CMD:mute(playerid,params[])
{
    new id, str[128], reason[50], time, timef;
    if(PlayerInfo[playerid][pAdmin] >= 1)
    {
        if(sscanf(params, "uis", id, time, reason))
            return SendClientMessage(playerid, DEEPPINK, "USAGE: /mute <id> <time> <reason>");
           
        if(id == INVALID_PLAYER_ID)
            return SendClientMessage(playerid, DEEPPINK, "ERROR: Player is not connected.");
           
        if(id == playerid)
            return SendClientMessage(playerid, DEEPPINK, "ERROR: You can't mute yourself.");
           
        if(time == 0)
            return SendClientMessage(playerid, DEEPPINK, "ERROR: Time must be more than 1 minute.");
           
        timef = time * 60000;
        SetTimerEx("unmute", timef, false, "i", id);
        format(str,sizeof(str),"{FFFFFF}Admin {D81417}%s {FFFFFF}(ID: %d) has muted {D81417}%s {FFFFFF}(ID: %d) for {D81417}%i {FFFFFF}minutes | Reason: {D81417}%s", GetPlayersName(playerid), playerid, GetPlayersName(id), id, time, reason);
        SendClientMessageToAll(-1 ,str);
        muted[id] = 1;
    }
    else return SendClientMessage(playerid, DEEPPINK, "ERROR: You must be level 1 to use that command!");
    return 1;
}
Reply
#2

timef = time * 60000;
60000 is 1 hour, or not?
Reply
#3

60 000 milliseconds = 1 minute
Reply
#4

Quote:
Originally Posted by MiGu3X
Посмотреть сообщение
60 000 milliseconds = 1 minute
Ah, okay
Reply
#5

pawn Код:
CMD:mute(playerid,params[])
{
    new id, str[128], reason[50], time;
    if(PlayerInfo[playerid][pAdmin] >= 1)
    {
        if(sscanf(params, "uis", id, time, reason))
            return SendClientMessage(playerid, DEEPPINK, "USAGE: /mute <id> <time> <reason>");

        if(id == INVALID_PLAYER_ID)
            return SendClientMessage(playerid, DEEPPINK, "ERROR: Player is not connected.");

        if(id == playerid)
            return SendClientMessage(playerid, DEEPPINK, "ERROR: You can't mute yourself.");

        if(time == 0)
            return SendClientMessage(playerid, DEEPPINK, "ERROR: Time must be more than 1 minute.");

        SetTimerEx("unmute", time*60*1000, false, "i", id);
        format(str,sizeof(str),"{FFFFFF}Admin {D81417}%s {FFFFFF}(ID: %d) has muted {D81417}%s {FFFFFF}(ID: %d) for {D81417}%i {FFFFFF}minutes | Reason: {D81417}%s", GetPlayersName(playerid), playerid, GetPlayersName(id), id, time, reason);
        SendClientMessageToAll(-1 ,str);
        muted[id] = 1;
    }
    else return SendClientMessage(playerid, DEEPPINK, "ERROR: You must be level 1 to use that command!");
    return 1;
}
Reply
#6

Won't work, i need to like killtimer and set muted to 0 ... . please help . . .
Reply
#7

MiGu3X you dont need to kill the timer you could just use 0 or false on SetTimerEx or SetTimer so it won't repeat

and after that time you set "when it finished" you can just set the variable

pawn Код:
muted[id] = 1;
To
pawn Код:
muted[id] = 0;
Hope you understand what i mean
Reply
#8

But how to see when timer finishes?
Reply
#9

In the timer just put muted[id] = 0;
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)