detect if player doesn't move for x seconds?
#3

When talking ONLY about the movement, not when keys are pushed etc, I'd do something similar:
Код:
enum afkInfo {
	Float:aX,
	Float:aY,
	Float:aZ,
	aCounter
};
new AFKPlayer[MAX_PLAYERS][afkInfo];


// Inside the timer:
for (new i = 0; i < MAX_PLAYERS; i++)
{
	new Float:x, Float:y, Float:z;
	GetPlayerPos(i, x, y, z);

	if (x == AFKPlayer[i][aX] && y == AFKPlayer[i][aY] && z == AFKPlayer[i][aZ])
	{
		AFKPlayer[i][aCounter]++;

		if (AFKPlayer[i][aCounter] >= 15) // player has been AFk for 15 seconds or more
		{
			// Do things you want to do if player is AFK
		}
	}
	else
	{
		AFKPlayer[i][aX] = x;
		AFKPlayer[i][aY] = y;
		AFKPlayer[i][aZ] = z;
		AFKPlayer[i][aCounter] = 0;
	}
}
The timer part you will have to figure out yourself, but it's not really hard! Note that OnPlayerUpdate is not fully reliable as it is called multiple times per second sometimes, depending on what is happening:
Quote:
This callback is called, on average, 30 times per second, per player; only use it when you know what it's meant for (or more importantly what it's NOT meant for).
The frequency with which this callback is called for each player varies, depending on what the player is doing. Driving or shooting will trigger a lot more updates than idling.
Reply


Messages In This Thread
detect if player doesn't move for x seconds? - by Bondz - 04.11.2016, 05:51
Re: detect if player doesn't move for x seconds? - by VVWVV - 04.11.2016, 06:28
Re: detect if player doesn't move for x seconds? - by Hansrutger - 04.11.2016, 06:32
Re: detect if player doesn't move for x seconds? - by Bondz - 04.11.2016, 07:04
Re: detect if player doesn't move for x seconds? - by Micko123 - 04.11.2016, 07:07
Re: detect if player doesn't move for x seconds? - by Threshold - 04.11.2016, 07:52
Re: detect if player doesn't move for x seconds? - by Micko123 - 04.11.2016, 08:13
Re: detect if player doesn't move for x seconds? - by Dayrion - 04.11.2016, 09:07

Forum Jump:


Users browsing this thread: 1 Guest(s)