Detecting movement
#1

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.
Reply
#2

GetPlayerPos - 2minutes - GetPlayerPos. If both positions are the same, set them as AFK.
Reply
#3

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]);
    }
}
Reply
#4

Yes. I just wanted it confirmed. Thank you both.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)