10.09.2016, 07:27
try this function, also use char var in it so you will save more memory usage.
also you don't need "stock" in this function.
Char: https://sampwiki.blast.hk/wiki/Keywords:Operators#char
Stock: https://sampforum.blast.hk/showthread.php?tid=570635
also be sure to do
at onplayerconnect callback.
also you don't need "stock" in this function.
PHP Code:
new SpamCount[MAX_PLAYERS char], ChatSpamTime[MAX_PLAYERS char];
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;
}
Stock: https://sampforum.blast.hk/showthread.php?tid=570635
also be sure to do
PHP Code:
ChatSpamTime{playerid} = 0;
SpamCount{playerid} = 0;