09.09.2016, 09:46
(
Last edited by Tass007; 10/09/2016 at 06:10 AM.
)
Hey guys, I got this script. It complies fine but there's a bug that I'm not quite sure how to fix.
When you spam the chat so say I repeat the message "Bob" 4 times I get the message "[Anti-Spam]: Warning you are one message away from being muted!" If you message Bob 1 more time in 4 seconds you get muted. That works fine. However if you send "Bob" 4 times after the 4 seconds is over you don't get muted and never can unless you reconnect. So the script isn't resetting itself properly. Not sure how to do it.
When you spam the chat so say I repeat the message "Bob" 4 times I get the message "[Anti-Spam]: Warning you are one message away from being muted!" If you message Bob 1 more time in 4 seconds you get muted. That works fine. However if you send "Bob" 4 times after the 4 seconds is over you don't get muted and never can unless you reconnect. So the script isn't resetting itself properly. Not sure how to do it.
PHP Code:
stock AntiSpam(playerid)
{
new msg[145];
SpamCount[playerid]++;
switch(SpamCount[playerid])
{
case 1:
{
ChatSpamTime[playerid][0]=gettime();
}
case 2:
{
if((gettime()-ChatSpamTime[playerid][0])<4)
{
ChatSpamTime[playerid][1]=gettime();
}
else SpamCount[playerid]=0;
}
case 3:
{
if((gettime()-ChatSpamTime[playerid][1])<4)
{
SendClientMessage(playerid, 0xFFFFFF, "[Anti-Spam]: Warning you are one message away from being muted!");
format(msg,sizeof(msg),"[Flood Control] - %s has been warned for flooding",GetName(playerid));
ABroadCast(COLOR_ADMIN,msg,1);
ChatSpamTime[playerid][2]=gettime();
}
else SpamCount[playerid]=0;
}
case 4..50:
{
if((gettime()-ChatSpamTime[playerid][2])<4)
{
format(msg, sizeof(msg), "[Anti-Spam]: %s has been muted for 5 minutes! (Reason: Spam)", GetName(playerid));
SendClientMessageToAll(0xFFFFFF, msg);
SendClientMessage(playerid,COLOR_GREEN,"You have received your final warning! You are now muted");
PlayerInfo[playerid][muted] = 1;
print(msg);
SetTimerEx("AutoUnMute",AutoUnmuteTime*60000,false,"i",playerid);
}
}
}
return 1;
}