Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- forward OnPlayerPaused(playerid);
- forward OnPlayerUnpaused(playerid);
- enum e_Player
- {
- Count,
- bool:Paused
- }
- static PlayerPauseInfo[MAX_PLAYERS][e_Player];
- new pauseTimer;
- #define IsPlayerPaused(%1) PlayerPauseInfo[%1][Paused]
- public OnGameModeInit()
- {
- pauseTimer = SetTimer("CheckPausedPlayers", 1000, true);
- }
- #if defined _ALS_OnGameModeInit
- #undef OnGameModeInit
- #else
- #define _ALS_OnGameModeInit
- #endif
- #define OnGameModeInit Pause_OnGameModeInit
- forward Pause_OnGameModeInit();
- public OnPlayerConnect(playerid)
- {
- PlayerPauseInfo[playerid][Paused] = false;
- return 1;
- }
- #if defined _ALS_OnPlayerConnect
- #undef OnPlayerConnect
- #else
- #define _ALS_OnPlayerConnect
- #endif
- #define OnPlayerConnect Pause_OnPlayerConnect
- forward Pause_OnPlayerConnect(playerid);
- public OnPlayerUpdate(playerid)
- {
- PlayerPauseInfo[playerid][Count] = 0;
- if(PlayerPauseInfo[playerid][Paused])
- {
- CallLocalFunction("OnPlayerUnpaused", "i", playerid);
- PlayerPauseInfo[playerid][Paused] = false;
- }
- return 1;
- }
- #if defined _ALS_OnPlayerUpdate
- #undef OnPlayerUpdate
- #else
- #define _ALS_OnPlayerUpdate
- #endif
- #define OnPlayerUpdate Pause_OnPlayerUpdate
- forward Pause_OnPlayerConnect(playerid);
- stock pause_IsPlayerSpawned(playerid) // By Goldkiller
- {
- new PlayerState = GetPlayerState(playerid);
- return (PlayerState != PLAYER_STATE_NONE && PlayerState != PLAYER_STATE_WASTED && PlayerState != PLAYER_STATE_SPECTATING);
- }
- forward CheckPausedPlayers(playerid);
- public CheckPausedPlayers()
- {
- #if defined foreach
- foreach(Player, playerid)
- #else
- for(new playerid = 0, players = GetMaxPlayers(); playerid != players; playerid++)
- #endif
- {
- if(pause_IsPlayerSpawned(playerid) && !PlayerPauseInfo[playerid][Paused])
- {
- PlayerPauseInfo[playerid][Count] ++;
- if(PlayerPauseInfo[playerid][Count] > 2)
- {
- CallLocalFunction("OnPlayerPaused", "i", playerid);
- PlayerPauseInfo[playerid][Paused] = true;
- }
- }
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement