02.12.2011, 21:35
hi,
my attempt to make an anti spam:
But it is buggy, the first time i write smth. its ok but then it gives me the 2 warnings and then it mutes me. (no matter how long i w8 untill i write smth. in the chat again.)
As soon as someone chats more than 1 line in 4 secs he shall be muted.
Would be happy about some help
my attempt to make an anti spam:
pawn Код:
new SpamCount[MAX_PLAYERS];
new ChatSpamTime[MAX_PLAYERS][2];
public OnPlayerText(playerid, text[])
{
if(muted[playerid] == 1)
{
SendClientMessage(playerid, 0xFF0000FF, "You have been muted!");
return 0;
}
else
{
new string[192], name[24];
GetPlayerName(playerid,name,24);
SpamCount[playerid]++;
ChatSpamTime[playerid][0]=gettime();
AntiSpam(playerid);
}
return 1;
}
stock AntiSpam(playerid)
{
new SpamProof[MAX_PLAYERS];
ChatSpamTime[playerid][1]=gettime();
SpamProof[playerid] = ChatSpamTime[playerid][1]-ChatSpamTime[playerid][0];
if(SpamCount[playerid]==2)
{
if(SpamProof[playerid]<4)
{
SendClientMessage(playerid,0xFF0000FF,"You got a warning for spamming");
}
else SpamCount[playerid]=0;
}
if(SpamCount[playerid]==3)
{
if(SpamProof[playerid]<4)
{
SendClientMessage(playerid,0xFF0000FF,"You got a warning for spamming");
}
else SpamCount[playerid]=0;
}
if(SpamCount[playerid]>=4)
{
new strings[128],names[24];
GetPlayerName(playerid,names,24);
if(SpamProof[playerid]<4)
{
format(strings,sizeof(strings),"%s has been muted for spamming",names);
SendClientMessageToAll(0xFF0000FF,strings);
muted[playerid] = 1;
}
}
return 1;
}
As soon as someone chats more than 1 line in 4 secs he shall be muted.
Would be happy about some help