-.Paradox.- Posted May 24, 2014 Share Posted May 24, 2014 Hello, Can you guys help me here? I'm trying to make an Away from keyboard Script, So when the player don't move his cursor or use any keyboard bindthen it will set his element data to "AFK" and if he was an admin it will set him to "Busy" once he move his "AFK/Busy" Element Data should be removed, Maybe there is something missing, here is my script, Thanks. Client: function mouseMove() setElementData(localPlayer, "Mouse", "Moving") end addEventHandler( "onClientCursorMove", getRootElement(), mouseMove) function usingKeyboard() setElementData(localPlayer, "Keyboard", "Using") end addEventHandler( "onClientKey", getRootElement(), mouseMove) function checkThem() if getElementData(localPlayer, "Keyboard") == false then setElementData(localPlayer, "Keyboard", "NotUsing") elseif getElementData(localPlayer, "Mouse") == false then setElementData(localPlayer, "Mouse", "NotMoving") end setTimer(checkThem, 1000, 1) Server: function checkAFKPlayers() for index, thePlayer in ipairs(getElementsByType("player"))do local acl = getElementData(thePlayer, "ACL") if (getPlayerIdleTime(thePlayer) > 3000) then -- Player hasn't moved for 120,000ms (2 minutes) setElementData(thePlayer, "AFK/Busy", "AFK") if acl and (getPlayerIdleTime(thePlayer) > 3000) then setElementData(thePlayer, "AFK/Busy", "Busy") end else if getElementData(thePlayer, "AFK/Busy") and (getElementData(thePlayer, "Keyboard", "NotUsing")) and (getElementData(thePlayer, "Mouse", "NotMoving")) then setElementData(thePlayer, "AFK/Busy", false) setElementData(thePlayer, "Keyboard", "Using") setElementData(thePlayer, "Mouse", "Moving") end end end end setTimer(checkAFKPlayers, 1000, 0) I don't know if there is a function to check if the player is using his keyboard or moving his mouse that's why i used ElementData, Thanks. P.S: The check if the player is admin is getElementData(thePlayer, "ACL") 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