help with mute timer
#1

Im making mute with timer, but when I mute someone he gets unmuted at the same time. I mean mute_time is not saving to variable, whats wrong?

pawn Код:
#define MUTE_TIME 10000

CMD:mute(playerid, params[])
{
new Msg[180];
new pID;

new MuteID, MuteStr[128], MuteReason[128];
if (sscanf(params, "us",MuteID,MuteReason)) return SendClientMessage(playerid, COLOR_RED, "[SERVER]: usage: \"/mute [id] [reason\"");
if(IsPlayerConnected(MuteID))
{
MuteTimer[MuteID] = SetTimerEx("PlayerUnMute",PlayerData[playerid][Muted]*MUTE_TIME,0,"d",MuteID);
format(Msg, sizeof(Msg), "adm: %s(%d) muted player %s(%d) reason %s", pName(playerid), playerid, pName(pID), pID, params);
SendClientMessageToAll(COLOR_RED, Msg);
}
return 1;
}
Thats my mute time load code on login callback:


pawn Код:
if(PlayerData[playerid][Muted] >= 1)
{
MuteTimer[playerid] = SetTimerEx("PlayerUnMute",PlayerData[playerid][Muted]*MUTE_TIME,0,"d",playerid);
return false;
}
Reply
#2

Quote:
Originally Posted by jaksimaksi
Посмотреть сообщение
Im making mute with timer, but when I mute someone he gets unmuted at the same time. I mean mute_time is not saving to variable, whats wrong?

pawn Код:
#define MUTE_TIME 10000

CMD:mute(playerid, params[])
{
new Msg[180];
new pID;

new MuteID, MuteStr[128], MuteReason[128];
if (sscanf(params, "us",MuteID,MuteReason)) return SendClientMessage(playerid, COLOR_RED, "[SERVER]: usage: \"/mute [id] [reason\"");
if(IsPlayerConnected(MuteID))
{
MuteTimer[MuteID] = SetTimerEx("PlayerUnMute",PlayerData[playerid][Muted]*MUTE_TIME,0,"d",MuteID);
format(Msg, sizeof(Msg), "adm: %s(%d) muted player %s(%d) reason %s", pName(playerid), playerid, pName(pID), pID, params);
SendClientMessageToAll(COLOR_RED, Msg);
}
return 1;
}
Thats my mute time load code on login callback:


pawn Код:
if(PlayerData[playerid][Muted] >= 1)
{
MuteTimer[playerid] = SetTimerEx("PlayerUnMute",PlayerData[playerid][Muted]*MUTE_TIME,0,"d",playerid);
return false;
}
Two things you need to take care of, your MUTE_TIME is only 10 seconds and and you forgot to add PlayerData[MuteID][Muted] = 1;

So, if the player has not PlayerData[playerid][Muted] >= 1, it says he is to 0 and your MUTE_TIMER is 10000 = 0*10000 = 0.
Plus, it's aint calling the timer PlayerUnMute.

Plus, why calling a timer twice for the same time? The player will need to wait 20 seconds before talking.

If you want me to change things from your script, tell me.
Reply
#3

NEW FEATURES :
  • Admin can set time of their choice
  • Time Variable is optional
  • Default Mute Time = 1 min
  • Mute bug Fixed
CODE :
pawn Код:
new MuteTimer[MAX_PLAYERS];
CMD:mute(playerid,params[])
{
//  new Msg[180];
   
    new MuteID,MuteReason[128],MuteTime = 60;
    if(sscanf(params,"us[128]z",MuteID,MuteReason,MuteTime)) return SendClientMessage(playerid, COLOR_RED, "[SERVER]: usage: \"/mute [id] [reason] [time]\"");
    if(!IsPlayerConnected(MuteID)) return SendClientMessage(playerid,COLOR_RED,"Player is not connected");
    MuteTimer[MuteID] = SetTimerEx("PlayerUnMute",MuteTime*1000,false,"i",MuteID);
    format(Msg, sizeof(Msg), "adm: %s(%d) muted player %s(%d) reason %s", pName(playerid), playerid, pName(MuteID), MuteID, MuteReason);
    SendClientMessageToAll(COLOR_RED, Msg);
    return 1;
}

forward PlayerUnMute(playerid);
public PlayerUnMute(playerid)
{
    //Unmute here
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)