SA-MP Forums Archive
Mute commad bug - 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 commad bug (/showthread.php?tid=557062)



Mute commad bug - Axey187 - 12.01.2015

pawn Код:
// ============ MUTE COMMAND ===================== //
CMD:mute(playerid, params[])
{
    new targetid, minutes, reason[128], string[128];
    if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_RED, "Player is not connected to the server");
    if(PlayerInfo[playerid][pAdmin] < 2) return SendClientMessage(playerid, COLOR_RED, "Command not found on server! /help");
    if(sscanf(params,"uis[128]", targetid, minutes, reason)) return SendClientMessage(playerid, COLOR_RED, "Mute: /mute (id) (minutes) (reason)");
    format(string, sizeof(string), "Administrator %s muted %s for %d minutes: %s", PlayerName(playerid), PlayerName(targetid), minutes, reason);
    SendClientMessageToAll(COLOR_RED, string);
    mutetimer = SetTimerEx("Unmute", minutes*60000, false, "i", playerid);
    PlayerInfo[playerid][Muted] == 1;
    new INI:File = INI_Open(UserPath(targetid));
    INI_SetTag(File,"data");
    INI_WriteInt(File,"Muted",1);
    INI_Close(File);
    return 1;
}
public Unmute(targetid)
{
    new targetid;
    PlayerInfo[targetid][Muted] == 0;
    new INI:File = INI_Open(UserPath(targetid));
    INI_SetTag(File,"data");
    INI_WriteInt(File,"Muted",0);
    INI_Close(File);
    SendClientMessage(targetid, COLOR_RED, "You have been unmuted automatically by server");
    return 1;
}
forward Unmute(targetid);
public OnPlayerText(playerid, text[])
{
    new string[128];
    if(PlayerInfo[playerid][Muted] == 1)
    {
        SendClientMessage(playerid,COLOR_RED,"You are muted, you are not allowed to talk!");
        return 0;
    }
    format(string,sizeof(string),"{%06x}%s (%d): {FFFFFF}%s",GetPlayerColor(playerid), PlayerName(playerid), playerid, text);
    SendClientMessageToAll(-1, string);
    return 0;
}
The Timer works and everything is fine, but the muted player is able to write in chat. What's wrong with my code here?


Re: Mute commad bug - Ironboy - 12.01.2015

Try this
pawn Код:
CMD:mute(playerid, params[])
{
    new targetid, minutes, reason[128], string[128];
    if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_RED, "Player is not connected to the server");
    if(PlayerInfo[playerid][pAdmin] < 2) return SendClientMessage(playerid, COLOR_RED, "Command not found on server! /help");
    if(sscanf(params,"uis[128]", targetid, minutes, reason)) return SendClientMessage(playerid, COLOR_RED, "Mute: /mute (id) (minutes) (reason)");
    format(string, sizeof(string), "Administrator %s muted %s for %d minutes: %s", PlayerName(playerid), PlayerName(targetid), minutes, reason);
    SendClientMessageToAll(COLOR_RED, string);
    SetTimerEx("Unmute", minutes*60000, false, "i", targetid);
    PlayerInfo[targetid][Muted] == 1;
    new INI:File = INI_Open(UserPath(targetid));
    INI_SetTag(File,"data");
    INI_WriteInt(File,"Muted",1);
    INI_Close(File);
    return 1;
}



Re: Mute commad bug - HY - 12.01.2015

pawn Код:
CMD:mute(playerid, params[])
{
    new targetid, minutes, reason[128], string[128];
    if(PlayerInfo[playerid][pAdmin] < 2) return SendClientMessage(playerid, COLOR_RED, "Command not found on server! /help");
    if(sscanf(params,"uis[128]", targetid, minutes, reason)) return SendClientMessage(playerid, COLOR_RED, "Mute: /mute (id) (minutes) (reason)");
    if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_RED, "Player is not connected to the server");
    format(string, sizeof(string), "Administrator %s muted %s for %d minutes: %s", PlayerName(playerid), PlayerName(targetid), minutes, reason);
    SendClientMessageToAll(COLOR_RED, string);
    mutetimer = SetTimerEx("Unmute", minutes*60000, false, "i", playerid);
    PlayerInfo[playerid][Muted] = 1;
    new INI:File = INI_Open(UserPath(targetid));
    INI_SetTag(File,"data");
    INI_WriteInt(File,"Muted",1);
    INI_Close(File);
    return 1;
}



Re: Mute commad bug - Clad - 12.01.2015

pawn Код:
public OnPlayerText(playerid, text[])
{
new string[128];
if(PlayerInfo[playerid][Muted] == 1)
{
SendClientMessage(playerid,COLOR_RED,"You are muted, you are not allowed to talk!");
return 0;
}
   else
   {
format(string,sizeof(string),"{%06x}%s (%d): {FFFFFF}%s",GetPlayerColor(playerid), PlayerName(playerid), playerid, text);
SendClientMessageToAll(-1, string);
return 0;
}