PDA

View Full Version : Auto-Mute + ChatLog


DarkKillerWithPride<3
01/01/2012, 09:42 PM
Hey,

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


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;
}


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:


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.

Jefff
01/01/2012, 10:29 PM
2. io_write to io_append

DarkKillerWithPride<3
01/01/2012, 10:30 PM
Ahh okay thanks man :D Any ideas on 1.?

Basssiiie
01/01/2012, 10:32 PM
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. ;)

DarkKillerWithPride<3
01/01/2012, 10:43 PM
Still Doesn't Work

Basssiiie
01/01/2012, 10:56 PM
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. ;)