Advertisement
DraKiNs

[COD] OnPlayerPause / UnPause

Aug 24th, 2011
599
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 1.41 KB | None | 0 0
  1. // Eficiente Anti-ESC (detect pause)
  2. // Criado por Bruno da Silva
  3. // Agradecimentos a The Moddler
  4. // www.ips-team.blogspot.com
  5.  
  6. // ================ [ Máximo de segundos em AFK ] =======================
  7.  
  8. #define MAX_AFK 2
  9.  
  10. // =============== [ Declarar variáveis ] ===============================
  11.  
  12. new
  13.     updateTime[MAX_PLAYERS],
  14.     bool:playerPaused[MAX_PLAYERS];
  15.  
  16. // ================== [ Iniciar a checagem de upTimers ] ==================
  17.  
  18. main()
  19. {
  20.     return SetTimer("updateTimers", 999, true), true;
  21. }
  22.  
  23. // ================ [  Armarzenar update do Jogador ] ======================
  24.  
  25. public OnPlayerUpdate(playerid)
  26. {
  27.     return updateTime[playerid] = gettime(), true;
  28. }
  29.  
  30.  
  31.  
  32. //================= [ Checar última OnPlayerUpdate ] =======================
  33.  
  34. updateTimers();
  35. public updateTimers()
  36. {
  37.     for(new i; i != MAX_PLAYERS; ++i) if(IsPlayerConnected(i))
  38.     {
  39.         if((GetPlayerPing(i) / 1000) < gettime() - updateTime[playerid] > MAX_AFK && !playerPaused[i] && GetPlayerState(i) && GetPlayerState(i) != 7)
  40.         {
  41.             CallRemoteFunction("OnPlayerPaused", "i", i);
  42.             playerPaused[i] = true;
  43.         }
  44.         else
  45.         if(playerPaused[i] && gettime() - updateTime[playerid] < MAX_AFK) CallRemoteFunction("OnPlayerUnpaused", "i", i),  playerPaused[playerid] = false;
  46.     }
  47.     return true;
  48. }
  49.  
  50. //=============== [ Declarar variáveis publicas ] ===========================
  51.  
  52. OnPlayerPaused(playerid);
  53. OnPlayerUnpaused(playerid);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement