Gravestone Posted June 1, 2016 Share Posted June 1, 2016 (edited) 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 June 1, 2016 by Guest Link to comment
Moderators IIYAMA Posted June 1, 2016 Moderators Share Posted June 1, 2016 if getElementData(player, "AFK") then Or if getElementData(player, "AFK") == true then Link to comment
Gravestone Posted June 1, 2016 Author Share Posted June 1, 2016 I tried it already. In both cases, it will return the value true. The problem is something else, which I can't figure out. Link to comment
ozulus Posted June 1, 2016 Share Posted June 1, 2016 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
Gravestone Posted June 1, 2016 Author Share Posted June 1, 2016 Alright. Setting alpha back to normal when the mouse moves works. What about when the player moves? Link to comment
tosfera Posted June 1, 2016 Share Posted June 1, 2016 use onClientKey or onClientCharacter. They'll trigger once a player presses a button. Just add them to the function removeAFK. Link to comment
Gravestone Posted June 1, 2016 Author Share Posted June 1, 2016 It's working now. Thanks for the help. Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now