Guest User

[FS] Anti-Afk

a guest
Aug 27th, 2010
1,461
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 2.63 KB | None | 0 0
  1. //===== Sistema Anti AFK By.: Lucas Nicolas Base de um Grove alguma coisa =====//
  2.  
  3. //====================== Include(s) =======================//
  4. #include <a_samp>
  5. //========================= Define =========================//
  6. #define COLOR_ROXO 0xAA3333AA
  7. #define TEMPO 240000 // 4 Minutos em milisegundos
  8.  
  9. //======================== Forward ========================//
  10. forward AFK(playerid);
  11. forward Fora(playerid);
  12.  
  13. //======================== New ========================//
  14. new Float:Posicoes[MAX_PLAYERS][6];
  15. new TAFK[MAX_PLAYERS];
  16. new TFora[MAX_PLAYERS];
  17. new EstaAFK[MAX_PLAYERS] = 0;
  18.  
  19. //======================== Public ========================//
  20. public OnPlayerDisconnect(playerid, reason)
  21. {
  22.     KillTimer(TAFK[playerid]);
  23.     KillTimer(TFora[playerid]);
  24.     return 1;
  25. }
  26.  
  27. public OnPlayerSpawn(playerid)
  28. {
  29.     KillTimer(TAFK[playerid]);
  30.     KillTimer(TFora[playerid]);
  31.     TAFK[playerid] = SetTimerEx("AFK", TEMPO, 1, "i", playerid);
  32.     return 1;
  33. }
  34.  
  35. public AFK(playerid)
  36. {
  37.     GetPlayerPos(playerid, Posicoes[playerid][0], Posicoes[playerid][1], Posicoes[playerid][2]);
  38.     if(Posicoes[playerid][0] == Posicoes[playerid][3] && Posicoes[playerid][1] == Posicoes[playerid][4] && Posicoes[playerid][2] == Posicoes[playerid][5])
  39.     {
  40.         if(EstaAFK[playerid] == 0)
  41.         {
  42.             new string[256];
  43.             new nome[MAX_PLAYER_NAME];
  44.             GetPlayerName(playerid, nome, sizeof(nome));
  45.             format(string, sizeof(string), "[SERVER] %s foi kikado do servidor. Razão: AFK", nome);
  46.             SendClientMessageToAll(COLOR_ROXO, string);
  47.             Kick(playerid);
  48.             return 1;
  49.          }
  50.          else
  51.          {
  52.             Posicoes[playerid][3] = Posicoes[playerid][0];
  53.             Posicoes[playerid][4] = Posicoes[playerid][1];
  54.             Posicoes[playerid][5] = Posicoes[playerid][2];
  55.             KillTimer(TAFK[playerid]);
  56.             TAFK[playerid] = SetTimerEx("AFK", TEMPO, 1, "i", playerid);
  57.             return 1;
  58.         }
  59.     }
  60.     else
  61.     {
  62.         Posicoes[playerid][3] = Posicoes[playerid][0];
  63.         Posicoes[playerid][4] = Posicoes[playerid][1];
  64.         Posicoes[playerid][5] = Posicoes[playerid][2];
  65.         KillTimer(TAFK[playerid]);
  66.         TAFK[playerid] = SetTimerEx("AFK", TEMPO, 1, "i", playerid);
  67.         return 1;
  68.     }
  69. }
  70.  
  71. public Fora(playerid)
  72. {
  73.     EstaAFK[playerid] = 0;
  74.     return 1;
  75. }
  76.  
  77. public OnPlayerText(playerid, text[])
  78. {
  79.     if(EstaAFK[playerid] == 0)
  80.     {
  81.         TFora[playerid] = SetTimerEx("Fora", 60000, 1, "i", playerid);
  82.         EstaAFK[playerid] = 1;
  83.         return 1;
  84.     }
  85.     else if(EstaAFK[playerid] == 1)
  86.     {
  87.         KillTimer(TFora[playerid]);
  88.         TFora[playerid] = SetTimerEx("Fora", 60000, 1, "i", playerid);
  89.         EstaAFK[playerid] = 1;
  90.         return 1;
  91.     }
  92.     return 0;
  93. }
  94.  
  95. // By GROVE4L
Advertisement
Add Comment
Please, Sign In to add comment