Ingame Check
#1

How can I check if a player is ingame or on the desktop?
Reply
#2

it should have a timer by the nameplate if they are tabbed out
Reply
#3

yes but I want to check it in the script
Reply
#4

I want to have a stock like "IsPlayerInGame" or "IsPlayerOnDesktop" :3
Reply
#5

You can't detect if they are in the desktop but if they are AFK or paused.

http://forum.sa-mp.com/showthread.ph...=onplayerpause
Reply
#6

You can only detect if a player stops sending network updates (OnPlayerUpdate). This includes:

- Crashed/Crashing
- Minimised/Alt-Tabbed (Desktop)
- Pause (ESC)
- Taking a screenshot
- Lagging
Reply
#7

The easiest way to do this is have a player variable which is set to zero under OnPlayerUpdate and having a timer which adds one to this variable. Then if you want to check if they are tabbed simply check if the variable is greater than 2. It's about 98 percent accurate because some people do de-sync or something else causes OnPlayerUpdate to not call. If you need an example just ask but it's not difficult to do at all.
Reply
#8

Quote:
Originally Posted by Chenko
Посмотреть сообщение
The easiest way to do this is have a player variable which is set to zero under OnPlayerUpdate and having a timer which adds one to this variable. Then if you want to check if they are tabbed simply check if the variable is greater than 2. It's about 98 percent accurate because some people do de-sync or something else causes OnPlayerUpdate to not call. If you need an example just ask but it's not difficult to do at all.
Could you give me an example please?
Reply
#9

Код:
OnPlayerUpdate()
{
     PlayerLogged[playerid] == 0;
}
OnGameModeInit()
{
      SetTimer("CheckFunc",10,0);
}
public CheckFun()
{
 
     for(new i = MAX_PLAYERS;i > 0;i--)
    {
          if(IsPlayerConnected(i))
          {
                PlayerLogged[i]++;
                 if(PlayerLogged[i] > 2) { SendClientMessage(playerid,COLOR_RED,"TIMED"); Kick(playerid); //The client mesg qwont work becaz its just before kick :P
          }
    }
}
Something like this ^^
Reply
#10

I have it already (not quite the same), but thank you anyway
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)