/mute issue
#1

I've got this admin system recently, but I'm facing issues with the /mute command, it works actually, but I can still chat..
Here's the mute command:
pawn Код:
COMMAND:mute(playerid,params[])
{
    if(PlayerInfo[playerid][AdminLevel] >= LEVEL_mute)
    {
        new player, time, reason[128];
        if(sscanf(params, "rds[128]", player, time, reason))
        {
            SendClientMessage(playerid,RED,"Usage: /mute <playerid/part of nick> <seconds> <reason>");
            return 1;
        }
        if(PlayerInfo[player][Muted] == true)
        {
            SendClientMessage(playerid,RED,"This player is already muted");
            return 1;
        }
        if(IsPlayerConnected(player) && player != INVALID_PLAYER_ID)
        {
           
            PlayerInfo[player][Muted] = true;
            format(string,sizeof(string),"**%s has been muted by Admin '%s' for %d seconds [Reason: %s]",GetName(player), GetName(playerid), time, reason);
            SendClientMessageToAll(YELLOW,string);
            PlayerInfo[player][MuteTimer] = SetTimerEx("unmute",time*1000, false, "d", player);
        }
        else
        {
            SendClientMessage(playerid, RED, "Player is not connected!");
        }
    }
    else
    {
        SendClientMessage(playerid, RED, NO_PERM);
    }
    return 1;
}
This is the OnPlayerText callback, all of it:
pawn Код:
public OnPlayerText(playerid, text[])
{
    if(text[0] == '!')
    {
        GetPlayerName(playerid, string, sizeof(string));
        format(string, sizeof(string), "[TEAM] {0000FF}%s {FFFF00}({FF0000}%d{FFFF00}): {88AA88}%s", string, playerid, text[1]);
        for(new i = 0; i < MAX_PLAYERS; i++)
        {
            if(IsPlayerConnected(i) && gTeam[i] == gTeam[playerid]) SendClientMessage(i, TEAM_MSG, string);
        }
        if(PlayerInfo[playerid][Logged] != true)
    {
        SendClientMessage(playerid, GREY, "You need to login to use the chat");
        return 0;
    }

        if(ServerInfo[EnableChat] == false)
        {
        SendClientMessage(playerid, GREY, "The chat has been disabled");
        return 0;
        }

    #if USE_VIP_SYSTEM == true
    if(text[0] == '!' && PlayerInfo[playerid][VIPLevel] >= 1)
    {
       
        GetPlayerName(playerid,string,sizeof(string));
        format(string,sizeof(string),"VIP Chat %s: %s",string,text[1]);
        VIPMSG(ORANGE,string);
        return 0;
    }
    #endif

    #if ENABLE_ADMIN_CHAT == true
    if(text[0] == '#' && PlayerInfo[playerid][AdminLevel] >= 1)
    {
       
        GetPlayerName(playerid,string,sizeof(string));
        format(string,sizeof(string),"Admin Chat %s: %s",string,text[1]);
        AdminMSG(GREEN,string);
        return 0;
    }
    #endif

    #if USE_ANTI_ADS == true
    new
        is1 = 0,
        r = 0,
        strR[255];

    while(strlen(text[is1]))
    {
        if('0' <= text[is1] <= '9')
        {
            new is2 = is1 + 1, p=0;

            while(p == 0)
            {
                if('0' <= text[is2] <= '9' && strlen(text[is2]))
                {
                   is2++;
                }
                else
                {
                    strmid(strR[r], text, is1, is2, sizeof(strR));
                    if(strval(strR[r]) < sizeof(strR)) r++;
                    is1 = is2;
                    p = 1;
                }
            }
        }
        is1++;
    }
    if(r >= 4)
    {
        SendClientMessage(playerid, RED, "Advertising is not allowed");
        return 0;
    }
    #endif


    else if(ServerInfo[NoCaps] == true)
    {
        UpperToLower(text);
    }

    else if(PlayerInfo[playerid][Muted] == true)
    {
       SendClientMessage(playerid, RED,"You have been muted! Please wait until the time is over!");
       return 1;
    }
    else
    {
        #if USE_CHAT_BUBBELS == true
        new cbMSG[150];
        format(cbMSG,sizeof(cbMSG),"%s", text);
        SetPlayerChatBubble(playerid, cbMSG, WHITE, 65.0, 8000);
        #endif

        #if USE_ID_MESSAGES == true
        new idMSG[150];
        format(idMSG,sizeof(idMSG),"%s (%d): {FFFFFF}%s", GetName(playerid), playerid, text);
        SendClientMessageToAll(GetPlayerColor(playerid), idMSG);
        #endif
    }
        return 0;
    }
    return 1;
}
Hmm? I need suggestions as soon as possible please.
Reply
#2

Bump. ._.
Reply
#3

change in OnPlayerText
pawn Код:
}
    return 1;
}
on
pawn Код:
}
    return 0;
}
Reply
#4

Try these:

pawn Код:
COMMAND:mute(playerid,params[])
{
    if(PlayerInfo[playerid][AdminLevel] < LEVEL_mute) return SendClientMessage(playerid, RED, NO_PERM);
    new player, time, reason[128];
    if(sscanf(params, "udS(No Reason)[128]", player, time, reason)) return SendClientMessage(playerid, RED, "Usage: /mute <playerid/part of nick> <seconds> <reason>");
    if(!IsPlayerConnected(player) || player == INVALID_PLAYER_ID) return SendClientMessage(playerid, RED, "Player is not connected!");
    if(PlayerInfo[player][Muted]) return SendClientMessage(playerid,RED,"This player is already muted");
    PlayerInfo[player][Muted] = true;
    new str[128];
    format(str,sizeof(str),"**%s has been muted by Admin '%s' for %d seconds [Reason: %s]", GetName(player), GetName(playerid), time, reason);
    SendClientMessageToAll(YELLOW, str);
    PlayerInfo[player][MuteTimer] = SetTimerEx("unmute", time * 1000, false, "d", player);
    return 1;
}

public OnPlayerText(playerid, text[])
{
    if(!PlayerInfo[playerid][Logged]) return SendClientMessage(playerid, GREY, "You need to login to use the chat");
    if(text[0] == '!')
    {
        new str[128];
        format(str, sizeof(str), "[TEAM] {0000FF}%s {FFFF00}(%d): {88AA88}%s", GetName(playerid), playerid, text[1]);
        for(new i = 0; i < MAX_PLAYERS; i++)
        {
            if(!IsPlayerConnected(i)) continue;
            if(gTeam[i] == gTeam[playerid]) SendClientMessage(i, TEAM_MSG, str);
        }
    }
    if(!ServerInfo[EnableChat]) return SendClientMessage(playerid, GREY, "The chat has been disabled");

    #if USE_VIP_SYSTEM == true
        //NOTE That if you are a VIP, you will send a message to VIP Chat AND team chat.
        if(text[0] == '!' && PlayerInfo[playerid][VIPLevel] >= 1)
        {
            new str[128];
            format(str, sizeof(str), "VIP Chat %s: %s", GetName(playerid), text[1]);
            VIPMSG(ORANGE,str);
            return 0;
        }
    #endif

    #if ENABLE_ADMIN_CHAT == true
        if(text[0] == '#' && PlayerInfo[playerid][AdminLevel] >= 1)
        {
            new str[128];
            format(str,sizeof(str),"Admin Chat %s: %s", GetName(playerid), text[1]);
            AdminMSG(GREEN,str);
            return 0;
        }
    #endif

    #if USE_ANTI_ADS == true
        new
            is1 = 0,
            r = 0,
            strR[255];

        while(strlen(text[is1]))
        {
            if('0' <= text[is1] <= '9')
            {
                new is2 = is1 + 1, p=0;

                while(p == 0)
                {
                    if('0' <= text[is2] <= '9' && strlen(text[is2]))
                    {
                       is2++;
                    }
                    else
                    {
                        strmid(strR[r], text, is1, is2, sizeof(strR));
                        if(strval(strR[r]) < sizeof(strR)) r++;
                        is1 = is2;
                        p = 1;
                    }
                }
            }
            is1++;
        }
        if(r >= 4) return SendClientMessage(playerid, RED, "Advertising is not allowed");
    #endif
   
    if(PlayerInfo[playerid][Muted]) return SendClientMessage(playerid, RED,"You have been muted! Please wait until the time is over!");
    if(ServerInfo[NoCaps]) UpperToLower(text);
    #if USE_CHAT_BUBBELS == true
        SetPlayerChatBubble(playerid, text, WHITE, 65.0, 8000);
    #endif

    #if USE_ID_MESSAGES == true
        format(text, 128, "%s (%d): {FFFFFF}%s", GetName(playerid), playerid, text);
    #endif
    return 1;
}
Returning 1 under OnPlayerText will send the original message. Returning 0 will stop the message sending, thus SendClientMessage(ToAll) must be used.
Reply
#5

Quote:
Originally Posted by BenzoAMG
Посмотреть сообщение
Try these:

pawn Код:
COMMAND:mute(playerid,params[])
{
    if(PlayerInfo[playerid][AdminLevel] < LEVEL_mute) return SendClientMessage(playerid, RED, NO_PERM);
    new player, time, reason[128];
    if(sscanf(params, "udS(No Reason)[128]", player, time, reason)) return SendClientMessage(playerid, RED, "Usage: /mute <playerid/part of nick> <seconds> <reason>");
    if(!IsPlayerConnected(player) || player == INVALID_PLAYER_ID) return SendClientMessage(playerid, RED, "Player is not connected!");
    if(PlayerInfo[player][Muted]) return SendClientMessage(playerid,RED,"This player is already muted");
    PlayerInfo[player][Muted] = true;
    new str[128];
    format(str,sizeof(str),"**%s has been muted by Admin '%s' for %d seconds [Reason: %s]", GetName(player), GetName(playerid), time, reason);
    SendClientMessageToAll(YELLOW, str);
    PlayerInfo[player][MuteTimer] = SetTimerEx("unmute", time * 1000, false, "d", player);
    return 1;
}

public OnPlayerText(playerid, text[])
{
    if(!PlayerInfo[playerid][Logged]) return SendClientMessage(playerid, GREY, "You need to login to use the chat");
    if(text[0] == '!')
    {
        new str[128];
        format(str, sizeof(str), "[TEAM] {0000FF}%s {FFFF00}(%d): {88AA88}%s", GetName(playerid), playerid, text[1]);
        for(new i = 0; i < MAX_PLAYERS; i++)
        {
            if(!IsPlayerConnected(i)) continue;
            if(gTeam[i] == gTeam[playerid]) SendClientMessage(i, TEAM_MSG, str);
        }
    }
    if(!ServerInfo[EnableChat]) return SendClientMessage(playerid, GREY, "The chat has been disabled");

    #if USE_VIP_SYSTEM == true
        //NOTE That if you are a VIP, you will send a message to VIP Chat AND team chat.
        if(text[0] == '!' && PlayerInfo[playerid][VIPLevel] >= 1)
        {
            new str[128];
            format(str, sizeof(str), "VIP Chat %s: %s", GetName(playerid), text[1]);
            VIPMSG(ORANGE,str);
            return 0;
        }
    #endif

    #if ENABLE_ADMIN_CHAT == true
        if(text[0] == '#' && PlayerInfo[playerid][AdminLevel] >= 1)
        {
            new str[128];
            format(str,sizeof(str),"Admin Chat %s: %s", GetName(playerid), text[1]);
            AdminMSG(GREEN,str);
            return 0;
        }
    #endif

    #if USE_ANTI_ADS == true
        new
            is1 = 0,
            r = 0,
            strR[255];

        while(strlen(text[is1]))
        {
            if('0' <= text[is1] <= '9')
            {
                new is2 = is1 + 1, p=0;

                while(p == 0)
                {
                    if('0' <= text[is2] <= '9' && strlen(text[is2]))
                    {
                       is2++;
                    }
                    else
                    {
                        strmid(strR[r], text, is1, is2, sizeof(strR));
                        if(strval(strR[r]) < sizeof(strR)) r++;
                        is1 = is2;
                        p = 1;
                    }
                }
            }
            is1++;
        }
        if(r >= 4) return SendClientMessage(playerid, RED, "Advertising is not allowed");
    #endif
   
    if(PlayerInfo[playerid][Muted]) return SendClientMessage(playerid, RED,"You have been muted! Please wait until the time is over!");
    if(ServerInfo[NoCaps]) UpperToLower(text);
    #if USE_CHAT_BUBBELS == true
        SetPlayerChatBubble(playerid, text, WHITE, 65.0, 8000);
    #endif

    #if USE_ID_MESSAGES == true
        format(text, 128, "%s (%d): {FFFFFF}%s", GetName(playerid), playerid, text);
    #endif
    return 1;
}
Returning 1 under OnPlayerText will send the original message. Returning 0 will stop the message sending, thus SendClientMessage(ToAll) must be used.
It is showing me the mute message, but I can still use the chat, and when I try to unmute myself, it says "The player is not muted". ._.

EDIT: Nevermind, I fixed it, thank you.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)