Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Pause check
- #define FPS_CHECKS 4
- new PlayerFPS[MAX_PLAYERS][FPS_CHECKS];
- new Paused[MAX_PLAYERS];
- new Text3D:pause[MAX_PLAYERS];
- new PausedTimer;
- forward PauseCheck();
- forward PlayerHasPaused(playerid);
- forward PlayerHasUnpaused(playerid);
- forward IsPlayerPaused(playerid);
- PausedTimer = SetTimer("PauseCheck", 1000, 1);//This is in OnGamodeInit
- KillTimer(PausedTimer);//This is in OnGamemodeExit
- Paused[playerid] = 0;// This is in OnPLayerConnect
- Paused[playerid] = 0;// OnPLayerDisconnect
- public PauseCheck()
- {
- new ps;
- for(new id=0; id < MAX_PLAYERS; id++)
- {
- if(!IsPlayerConnected(id)) continue;
- ps = GetPlayerState(id);
- if(ps != PLAYER_STATE_ONFOOT && ps != PLAYER_STATE_DRIVER && ps != PLAYER_STATE_PASSENGER) continue;
- for(new x = FPS_CHECKS-1; x > 0; x--)
- {
- PlayerFPS[id][x] = PlayerFPS[id][x - 1];
- }
- PlayerFPS[id][0] = GetPlayerDrunkLevel(id);
- for(new x = 0; x < FPS_CHECKS; x++)
- {
- if(x == FPS_CHECKS - 1)
- {
- if(Paused[id] != 1) PlayerHasPaused(id);
- Paused[id] = 1;
- break;
- }
- if(PlayerFPS[id][x] == PlayerFPS[id][x + 1]) continue;
- if(Paused[id] != 0) PlayerHasUnpaused(id);
- Paused[id] = 0;
- break;
- }
- if(PlayerFPS[id][0] < 100)
- {
- SetPlayerDrunkLevel(id, 2000);
- }
- }
- return 1;
- }
- public PlayerHasPaused(playerid) //HERE
- {
- new name[MAX_PLAYER_NAME];
- GetPlayerName(playerid, name, sizeof(name));
- new tmp[256];
- //new Float:x, Float:y, Float:z; GetPlayerPos(playerid,x,y,z);
- format(tmp, sizeof(tmp), "%s is Paused.",name);
- pause[playerid] = Create3DTextLabel(tmp, 0xC50000FF,30.0,40.0,50.0,40.0,0);
- Attach3DTextLabelToPlayer(pause[playerid],playerid, 0.0, 0.0, 0.3);
- return 1;
- }
- public PlayerHasUnpaused(playerid)
- {
- Delete3DTextLabel(pause[playerid]);
- return 1;
- }
- public IsPlayerPaused(playerid) return Paused[playerid];
Advertisement
Add Comment
Please, Sign In to add comment