27.04.2013, 13:33
How can I check if a player is ingame or on the desktop?
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.
|
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 } } }