Guest User

Untitled

a guest
Feb 13th, 2011
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 2.07 KB | None | 0 0
  1. // Pause check
  2. #define FPS_CHECKS 4
  3.  
  4. new PlayerFPS[MAX_PLAYERS][FPS_CHECKS];
  5. new Paused[MAX_PLAYERS];
  6. new Text3D:pause[MAX_PLAYERS];
  7. new PausedTimer;
  8.  
  9. forward PauseCheck();
  10. forward PlayerHasPaused(playerid);
  11. forward PlayerHasUnpaused(playerid);
  12. forward IsPlayerPaused(playerid);
  13.  
  14. PausedTimer = SetTimer("PauseCheck", 1000, 1);//This is in OnGamodeInit
  15.  
  16. KillTimer(PausedTimer);//This is in OnGamemodeExit
  17.  
  18. Paused[playerid] = 0;// This is in OnPLayerConnect
  19.  
  20. Paused[playerid] = 0;// OnPLayerDisconnect
  21.  
  22. public PauseCheck()
  23. {
  24.     new ps;
  25.     for(new id=0; id < MAX_PLAYERS; id++)
  26.     {
  27.         if(!IsPlayerConnected(id)) continue;
  28.         ps = GetPlayerState(id);
  29.         if(ps != PLAYER_STATE_ONFOOT && ps != PLAYER_STATE_DRIVER && ps != PLAYER_STATE_PASSENGER) continue;
  30.  
  31.         for(new x = FPS_CHECKS-1; x > 0; x--)
  32.         {
  33.             PlayerFPS[id][x] = PlayerFPS[id][x - 1];
  34.         }
  35.         PlayerFPS[id][0] = GetPlayerDrunkLevel(id);
  36.         for(new x = 0; x < FPS_CHECKS; x++)
  37.         {
  38.             if(x == FPS_CHECKS - 1)
  39.             {
  40.                 if(Paused[id] != 1) PlayerHasPaused(id);
  41.                 Paused[id] = 1;
  42.                 break;
  43.             }
  44.             if(PlayerFPS[id][x] == PlayerFPS[id][x + 1]) continue;
  45.             if(Paused[id] != 0) PlayerHasUnpaused(id);
  46.             Paused[id] = 0;
  47.             break;
  48.         }
  49.  
  50.         if(PlayerFPS[id][0] < 100)
  51.         {
  52.             SetPlayerDrunkLevel(id, 2000);
  53.         }
  54.     }
  55.     return 1;
  56. }
  57.  
  58. public PlayerHasPaused(playerid) //HERE
  59. {
  60.     new name[MAX_PLAYER_NAME];
  61.     GetPlayerName(playerid, name, sizeof(name));
  62.     new tmp[256];
  63.     //new Float:x, Float:y, Float:z; GetPlayerPos(playerid,x,y,z);
  64.     format(tmp, sizeof(tmp), "%s is Paused.",name);
  65.     pause[playerid] = Create3DTextLabel(tmp, 0xC50000FF,30.0,40.0,50.0,40.0,0);
  66.     Attach3DTextLabelToPlayer(pause[playerid],playerid, 0.0, 0.0, 0.3);
  67.     return 1;
  68. }
  69.  
  70. public PlayerHasUnpaused(playerid)
  71. {
  72.     Delete3DTextLabel(pause[playerid]);
  73.     return 1;
  74. }
  75.  
  76. public IsPlayerPaused(playerid) return Paused[playerid];
Advertisement
Add Comment
Please, Sign In to add comment