/mute issue
#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


Messages In This Thread
/mute issue - by MythicalMarauder - 13.03.2014, 23:04
Re: /mute issue - by MythicalMarauder - 13.03.2014, 23:38
Re: /mute issue - by Matess - 13.03.2014, 23:47
Re: /mute issue - by Threshold - 14.03.2014, 01:09
Re: /mute issue - by MythicalMarauder - 14.03.2014, 06:08

Forum Jump:


Users browsing this thread: 2 Guest(s)