Урок по созданию анти флуда на время если игрок слишком часто отправляет сообшения то эта функция его заткнет на 20 сек
в верху пишем
Код
new Muted[MAX_PLAYERS];
new Spamcounter[MAX_PLAYERS][2];
new mute0;
#define ANTI_SPAM 1
#define SPAM_MESSAGES 2
#define SPAM_TIMELIMIT 1
в
Код
public OnPlayerText(playerid, text[])
Код
#if ANTI_SPAM
SpamProtection(playerid);
#endif
new string[256];
if(Muted[playerid] == 1)
{
SendClientMessage(playerid, COLOR_YELLOW, "Âû íå ìîæåòå ãîâîðèòü, âû çàòêíóòû!");
return 0;
}
Внизу вписываем
Код
stock SpamProtection(playerid)
{
new string[64];
if(Spamcounter[playerid][0] == 0) { Spamcounter[playerid][1] = TimeStamp(); }
Spamcounter[playerid][0]++;
if(TimeStamp() - Spamcounter[playerid][1] > SPAM_TIMELIMIT)
{
Spamcounter[playerid][0] = 1;
Spamcounter[playerid][1] = TimeStamp();
}
else if(Spamcounter[playerid][0] == SPAM_MESSAGES)
{
// Mute[playerid] = 1;
// mutetime[playerid] += 20;
и
Код
forward PlayerUnMute(playerid);
public PlayerUnMute(playerid)
{
new string[256];
new playrname[MAX_PLAYER_NAME];
GetPlayerName(playerid, playrname, sizeof(playrname));
Muted[playerid] = 0;
format(string, sizeof(string), "Вы разоткнуты.", playrname);
SendClientMessage(playerid,COLOR_YELLOW, string);
return 1;
}
Код
stock oGetPlayerName(playerid)
{
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof (name));
return name;
}
Код
stock TimeStamp()
{
new time = GetTickCount()/1000;
return time;
}