Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //===== Sistema Anti AFK By.: Lucas Nicolas Base de um Grove alguma coisa =====//
- //====================== Include(s) =======================//
- #include <a_samp>
- //========================= Define =========================//
- #define COLOR_ROXO 0xAA3333AA
- #define TEMPO 240000 // 4 Minutos em milisegundos
- //======================== Forward ========================//
- forward AFK(playerid);
- forward Fora(playerid);
- //======================== New ========================//
- new Float:Posicoes[MAX_PLAYERS][6];
- new TAFK[MAX_PLAYERS];
- new TFora[MAX_PLAYERS];
- new EstaAFK[MAX_PLAYERS] = 0;
- //======================== Public ========================//
- public OnPlayerDisconnect(playerid, reason)
- {
- KillTimer(TAFK[playerid]);
- KillTimer(TFora[playerid]);
- return 1;
- }
- public OnPlayerSpawn(playerid)
- {
- KillTimer(TAFK[playerid]);
- KillTimer(TFora[playerid]);
- TAFK[playerid] = SetTimerEx("AFK", TEMPO, 1, "i", playerid);
- return 1;
- }
- public AFK(playerid)
- {
- GetPlayerPos(playerid, Posicoes[playerid][0], Posicoes[playerid][1], Posicoes[playerid][2]);
- if(Posicoes[playerid][0] == Posicoes[playerid][3] && Posicoes[playerid][1] == Posicoes[playerid][4] && Posicoes[playerid][2] == Posicoes[playerid][5])
- {
- if(EstaAFK[playerid] == 0)
- {
- new string[256];
- new nome[MAX_PLAYER_NAME];
- GetPlayerName(playerid, nome, sizeof(nome));
- format(string, sizeof(string), "[SERVER] %s foi kikado do servidor. Razão: AFK", nome);
- SendClientMessageToAll(COLOR_ROXO, string);
- Kick(playerid);
- return 1;
- }
- else
- {
- Posicoes[playerid][3] = Posicoes[playerid][0];
- Posicoes[playerid][4] = Posicoes[playerid][1];
- Posicoes[playerid][5] = Posicoes[playerid][2];
- KillTimer(TAFK[playerid]);
- TAFK[playerid] = SetTimerEx("AFK", TEMPO, 1, "i", playerid);
- return 1;
- }
- }
- else
- {
- Posicoes[playerid][3] = Posicoes[playerid][0];
- Posicoes[playerid][4] = Posicoes[playerid][1];
- Posicoes[playerid][5] = Posicoes[playerid][2];
- KillTimer(TAFK[playerid]);
- TAFK[playerid] = SetTimerEx("AFK", TEMPO, 1, "i", playerid);
- return 1;
- }
- }
- public Fora(playerid)
- {
- EstaAFK[playerid] = 0;
- return 1;
- }
- public OnPlayerText(playerid, text[])
- {
- if(EstaAFK[playerid] == 0)
- {
- TFora[playerid] = SetTimerEx("Fora", 60000, 1, "i", playerid);
- EstaAFK[playerid] = 1;
- return 1;
- }
- else if(EstaAFK[playerid] == 1)
- {
- KillTimer(TFora[playerid]);
- TFora[playerid] = SetTimerEx("Fora", 60000, 1, "i", playerid);
- EstaAFK[playerid] = 1;
- return 1;
- }
- return 0;
- }
- // By GROVE4L
Advertisement
Add Comment
Please, Sign In to add comment