10.09.2016, 08:08
ops, my mistake I used char in ChatSpamTime and bugged it lol try this .
also I used { } because I used SpamCount[MAX_PLAYERS char] not SpamCount[MAX_PLAYERS]
PHP Code:
new SpamCount[MAX_PLAYERS char], ChatSpamTime[MAX_PLAYERS];
AntiSpam(playerid)
{
new msg[145];
if((gettime()-ChatSpamTime[playerid]) > 5 || !ChatSpamTime[playerid])
{
SpamCount{playerid} = 1;
ChatSpamTime[playerid] = gettime();
}
else
{
SpamCount{playerid}++;
switch(SpamCount{playerid})
{
case 2:
{
ChatSpamTime[playerid] = gettime(); // <- update the time!
}
case 3:
{
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] = gettime();
}
case 4..99:
{
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);
ChatSpamTime[playerid] = 0;
SpamCount{playerid} = 0;
}
}
}
return 1;
}