Auto-Mute + ChatLog
#1

Hey,

Basically I attempted this script, I am trying to mute a player if the player spams 5 things:

pawn Код:
public OnPlayerText(playerid,text[])
{
    if(PlayerInfo[playerid][pMuted] == 1)
    {
        SendClientMessage(playerid,COLOR_RED,"You are currently muted.");
        SendClientMessage(playerid,COLOR_RED,"If you feel you shouldn't be muted then please /request unmute");
        SendClientMessage(playerid,COLOR_RED,"Do not abuse this system, you will be kicked and possibly banned.");
        return 0;
    }
    if(ChatSpamMuted[playerid] == 1)
    {
        SendClientMessage(playerid,COLOR_RED,"You are currently muted.");
        SendClientMessage(playerid,COLOR_RED,"If you feel you shouldn't be muted then please /request unmute");
        SendClientMessage(playerid,COLOR_RED,"Do not abuse this system, you will be kicked and possibly banned.");
        return 0;
    }
    ChatSpam[playerid] ++;
    SetTimer("ChatSpamClear",500,true);
    if(ChatSpam[playerid] == 5)
    {
        SendClientMessage(playerid,COLOR_RED,"Please Do Not Spam, You Have Been Muted");
        ChatSpamMuted[playerid] = 1;
        return 0;
    }
    ChatLog(text);
    return 1;
}
pawn Код:
public ChatSpamClear()
{
    for(new i = 0; i <MAX_PLAYERS; i++)
    {
        if(ChatSpam[i] >= 1)
        {
            ChatSpam[i] = 0;
        }
    }
    return 1;
}
Unfortunately that doesn't work the player spams then just stops talking and cannot enter any commands I spammed 30things, after around 15 it stopped working and stopped transmitting also while kind of on topic my ChatLog doesn't work as it should:

pawn Код:
public ChatLog(text[])
{
    new File:File = fopen("/Logs/ChatLog.txt",io_write);
    new Y,M,D,iH,iM,iS;
    getdate(Y,M,D);
    gettime(iH,iM,iS);
    new string[128];
    format(string,sizeof(string),"[%d/%d/%d - %d:%d]: %s\r\n",D,M,Y,iH,iM,text);
    fwrite(File,string);
    fclose(File);
    return 1;
}
That just prints the last chat line in the file so I only have: [1/1/2012 - 21:36]: ****: attt when it should be 50+ things, could anyone help?

Thanks In Advance.

DarkKiller.
Reply
#2

2. io_write to io_append
Reply
#3

Ahh okay thanks man Any ideas on 1.?
Reply
#4

You shouldn't start timers every time someone says something in the chat. In some minutes you have hundreds of timers running which just slow down the server and even freeze it.
Код:
SetTimer("ChatSpamClear",500,true);
Move that line to OnGameModeInit/OnFilterScriptInit and you'll be fine.
Reply
#5

Still Doesn't Work
Reply
#6

Код:
if(ChatSpam[playerid] == 5)
You have to change that to this:
Код:
if(ChatSpam[playerid] >= 5)
Because ChatSpam[playerid] still increases even if the player is muted.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)