ко всем define
Код: Выделить всё
#define GivePVarInt(%0,%1,%2) \
SetPVarInt(%0,%1,(GetPVarInt(%0,%1) + %2))
#define MAX_AFK 500 // секунд до кика
в OnGameModeInit
Код: Выделить всё
SetTimer("AFKSystem", 1000, 1); //Создаем таймер
в OnPlayerUpdate
Код: Выделить всё
SetPVarInt(playerid, "AFKTime", -2); // если игрок не в AFK переменная будет ровняться -2
в конец мода
Код: Выделить всё
forward AFKSystem();
public AFKSystem()
{
for(new i; i<GetMaxPlayers(); i++) //Запускаем цикл на всех игроков
{
if(IsPlayerConnected(i))
{
if(GetPVarInt(i, "AFKTime") == -1 || GetPVarInt(i, "AFKTime") == -2) GivePVarInt(i, "AFKTime", 1);
if(GetPVarInt(i, "AFKTime") >= 0)
{
GivePVarInt(i, "AFKTime", 1);
new str[32];
format(str,32,"[AFK]: %d сек.",GetPVarInt(i, "AFKTime"));
SetPlayerChatBubble(i,str,0x06A500FF,10.0,3000);
if(GetPVarInt(i, "AFKTime") > MAX_AFK)
{
SendClientMessage(i, 0xFF0000FF, "Вы были кикнуты за AFK (" #MAX_AFK " секунд)");
Kick(i);
}
}
}
}
return 1;
}