enum AFKInfo
{
AFKTimerEx,
AFKPause,
AFKPlay
};
new CheckAFKInfo[MAX_PLAYERS][AFKInfo];
public OnPlayerConnect(playerid)
{
CheckAFKInfo[playerid][AFKPlay] = 1;
CheckAFKInfo[playerid][AFKPause] = 0;
CheckAFKInfo[playerid][AFKTimerEx] = SetTimerEx("CheckPausePlayer", 500, true, "i",playerid);
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
KillTimer(CheckAFKInfo[playerid][AFKTimerEx]);
return 1;
}
public OnPlayerUpdate(playerid)
{
CheckAFKInfo[playerid][AFKPlay] = 1;
CheckAFKInfo[playerid][AFKPause] = 0;
return 1;
}
stock CheckPausePlayer(playerid)
{
CheckAFKInfo[playerid][AFKPlay]++;
if(CheckAFKInfo[playerid][AFKPlay] > 4)
{
CheckAFKInfo[playerid][AFKPause] = 1;
CheckAFKInfo[playerid][AFKPlay] = 0;
}
else
{
CheckAFKInfo[playerid][AFKPause] = 0;
CheckAFKInfo[playerid][AFKPlay] = 1;
}
return 1;
}
stock PlayerPause(playerid)
{
if(CheckAFKInfo[playerid][AFKPause] == 1 && CheckAFKInfo[playerid][AFKPlay] == 0)
{
return 1;
}
return 0;
}
stock PlayerPlay(playerid)
{
if(CheckAFKInfo[playerid][AFKPause] == 0 && CheckAFKInfo[playerid][AFKPlay] == 1)
{
return 1;
}
return 0;
}
public OnPlayerUpdate(playerid) {
SetPVarInt(playerid, "lastUpdate", gettime() );
return 1;
}
stock isPaused(playerid) {
if ( (gettime() - GetPVarInt(playerid, "lastUpdate") ) >= 1 )
return 1;
return 0;
}
Um jeito mais simples:
PHP код:
|
Vocк deve iniciar as variбveis quando as callbacks sгo chamadas
|
Recomendo a utilizaзгo desta Include para executar a checagem que vocк quer efetuar.
|