Ingame Check - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Ingame Check (
/showthread.php?tid=433469)
Ingame Check -
RayZar - 27.04.2013
How can I check if a player is ingame or on the desktop?
Re: Ingame Check -
Mwowwtittybang - 27.04.2013
it should have a timer by the nameplate if they are tabbed out
AW: Ingame Check -
RayZar - 27.04.2013
yes but I want to check it in the script
AW: Ingame Check -
RayZar - 27.04.2013
I want to have a stock like "IsPlayerInGame" or "IsPlayerOnDesktop" :3
Re: Ingame Check -
Tamer - 27.04.2013
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
Re: Ingame Check -
MP2 - 27.04.2013
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
Re: Ingame Check -
Chenko - 27.04.2013
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.
Re: Ingame Check -
selEcT - 03.05.2013
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?
Re: Ingame Check -
Yashas - 03.05.2013
Код:
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 ^^
Re: Ingame Check -
selEcT - 03.05.2013
I have it already (not quite the same), but thank you anyway