Антифлуд в чат.
Ко всем переменным:
PHP код:
new IsMessageSent[MAX_PLAYERS];
new interval = 2;
В конец макросов:
PHP код:
#if defined SendClientMessage SCM
#endif
В public OnPlayerConnect:
PHP код:
new conn[256];
IsMessageSent[playerid] = 0;
format(conn,sizeof(conn),"Anti-Flood активирован",interval);
SCM(playerid,0x33AA33AA,conn);
В public OnPlayerText:
PHP код:
if(IsMessageSent[playerid] == 1)
{
SCM(playerid, 0x4682B4AA, "Не флуди!");
return false;
}
else
{
IsMessageSent[playerid] = 1;
SetTimerEx("UnMutedX",interval*1000,0,"d",playerid);
return true;
}
Создадим колбек:
PHP код:
forward UnMutedX(playerid);
public UnMutedX(playerid)
{
IsMessageSent[playerid] = 0;
return true;
}
На этом всё. Спасибо за просмотр!