Detecting movement - 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: Detecting movement (
/showthread.php?tid=291655)
Detecting movement -
sim_sima - 20.10.2011
Hi guys.
Just a fast question on how to detect movement.
Well, i want to make a AFK system, that automatically puts a player in AFK mode if he hasn't moved for 2 minutes.
So how do I detect whether he has moved for 2 minutes or not?
I thourght about making a timer that gets the players position, and if he then is at the same position after 2 minutes, it will turn him AFK.
But maybe there is an easier way?
Thank you.
Re: Detecting movement -
Kingunit - 20.10.2011
GetPlayerPos - 2minutes - GetPlayerPos. If both positions are the same, set them as AFK.
Re: Detecting movement -
SuperViper - 21.10.2011
pawn Код:
#include <YSI\y_timers>
new Float:oldPos[MAX_PLAYERS][3];
Timer:AFKUpdate[120000]() {
new Float:tempPos[3];
foreach(Player, playerid) {
GetPlayerPos(playerid, tempPos[0], tempPos[1], tempPos[2]);
if(tempPos[0] == oldPos[playerid][0] && tempPos[1] == oldPos[playerid][1] && tempPos[2] == oldPos[playerid][2]) {
// AFK code
}
GetPlayerPos(playerid, oldPos[playerid][0], oldPos[playerid][1], oldPos[playerid][2]);
}
}
Re: Detecting movement -
sim_sima - 21.10.2011
Yes. I just wanted it confirmed. Thank you both.