SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 03/02/2012, 09:44 PM   #1
Luis-
High-roller
 
Luis-'s Avatar
 
Join Date: Jan 2010
Location: England
Posts: 3,933
Reputation: 415
Default Best way to detect if AFK

What is the best way to check if someone is AFK?
__________________
Luis- is offline   Reply With Quote
Old 03/02/2012, 10:17 PM   #2
shitbird
Gangsta
 
shitbird's Avatar
 
Join Date: Nov 2007
Posts: 719
Reputation: 31
Default Re: Best way to detect if AFK

Quote:
Originally Posted by -Luis View Post
What is the best way to check if someone is AFK?
Check the players coordinates, using GetPlayerPos.
Initialize a timer of 'x' seconds/minutes, checking his coordinates. If they match the previous coordinates. He hasn't moved.
Punish/Warn, as you please.
shitbird is offline   Reply With Quote
Old 03/02/2012, 10:20 PM   #3
jamesbond007
Gangsta
 
jamesbond007's Avatar
 
Join Date: Oct 2009
Location: Canadia
Posts: 787
Reputation: 56
Default Re: Best way to detect if AFK

Quote:
Originally Posted by shitbird View Post
Check the players coordinates, using GetPlayerPos.
Initialize a timer of 'x' seconds/minutes, checking his coordinates. If they match the previous coordinates. He hasn't moved.
Punish/Warn, as you please.

what if he hasnt moved -.-

once u stop moving u get kicked for AFK ? i think there is a better way..
jamesbond007 is offline   Reply With Quote
Old 03/02/2012, 10:24 PM   #4
MP2
Godfather
 
MP2's Avatar
 
Join Date: Jan 2011
Location: England
Posts: 6,236
Reputation: 1004
Default Re: Best way to detect if AFK

There's two ways. Movement with GetPlayerPos or updates with OnPlayerUpdate. One for not moving, one for being paused. Which one do you want? The playerpos one would do both.
__________________
Owner and developer of Mike's Cops and Robbers.

Click here to visit our site and find out more. Click here to view trailers.
Enter referral code SAMPFORUM after registering for a $5000 starting bonus!
MP2 is offline   Reply With Quote
Old 03/02/2012, 10:25 PM   #5
ғαιιοцт
High-roller
 
ғαιιοцт's Avatar
 
Join Date: Feb 2008
Posts: 1,428
Reputation: 188
Default Re: Best way to detect if AFK

Chech if OnPlayerUpdate is called.
Once you go afk, it won't get called anymore.

This is very accurate!


@MP2:
Damn, why are you always 1 second faster
ғαιιοцт is offline   Reply With Quote
Old 04/02/2012, 01:48 PM   #6
Luis-
High-roller
 
Luis-'s Avatar
 
Join Date: Jan 2010
Location: England
Posts: 3,933
Reputation: 415
Default Re: Best way to detect if AFK

This doesn't even compile, no doubt it is wrong.
pawn Code:
new Float:Pos[3], Float:OldPos[3], Float:NewPos[3];
    GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
    OldPos[0] = Pos[0];
    OldPos[1] = Pos[1];
    OldPos[2] = Pos[2];
    GetPlayerPos(playerid, NewPos[0], NewPos[1], NewPos[2]);
    if(OldPos[0] == NewPos[0]))
    {
        print("Player stopped moving");
    }

Error is: invalid expression, assumed zero.
__________________
Luis- is offline   Reply With Quote
Old 04/02/2012, 02:56 PM   #7
thimo
High-roller
 
thimo's Avatar
 
Join Date: Jan 2009
Location: Netherlands
Posts: 1,130
Reputation: 24
Default Re: Best way to detect if AFK

Wich line?
thimo is offline   Reply With Quote
Old 04/02/2012, 03:37 PM   #8
Luis-
High-roller
 
Luis-'s Avatar
 
Join Date: Jan 2010
Location: England
Posts: 3,933
Reputation: 415
Default Re: Best way to detect if AFK

This one,
Code:
if(OldPos[0] == NewPos[0]))
__________________
Luis- is offline   Reply With Quote
Old 04/02/2012, 07:41 PM   #9
Luis-
High-roller
 
Luis-'s Avatar
 
Join Date: Jan 2010
Location: England
Posts: 3,933
Reputation: 415
Default Re: Best way to detect if AFK

Can anyone help?
__________________
Luis- is offline   Reply With Quote
Old 04/02/2012, 07:47 PM   #10
xXpatoXx
Little Clucker
 
Join Date: Jan 2011
Posts: 2
Reputation: 0
Default AW: Best way to detect if AFK

Code:
if(OldPos[0] == NewPos[0]))
xXpatoXx is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
detect manchestera Scripting Help 1 21/10/2011 09:36 PM
Detect CJ Run? Antonio [G-RP] Help Archive 10 29/03/2011 08:53 AM
afk detect Amine_Mejrhirrou Help Archive 6 02/03/2011 12:24 PM
detect again willsuckformoney Help Archive 7 01/08/2010 07:27 AM
Detect radi Help Archive 5 19/07/2009 11:57 AM


All times are GMT. The time now is 03:29 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.