Jump to content

Detecting player movement


Recommended Posts

This code sets the player's alpha to 100 who goes afk for more than 45 seconds. It should set his alpha back to 255 when he moves hi mouse, moves himself or clicks any button.

Client side:

function removeAFK (player) 
    if getElementData(player, "AFK") == "true" then 
    setElementAlpha(player, 255) 
    end 
end 
addEventHandler("onClientMouseMove", root, removeAFK) 

The server side code does detect the movement but a bit late. And this client side scripts isn't detecting the movement. Thanks in advance.

Edited by Guest
Link to comment

Client side

function removeAFK() --there isn't player arg. in onClientMouseMove event. check wiki for available arguments of event. 
    if getElementData(localPlayer, "AFK") then 
         setElementAlpha(localPlayer, 255) 
         --note: in client-side, source(player) is localPlayer. 
    end 
end 
addEventHandler("onClientMouseMove", root, removeAFK) 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...