xTravax Posted April 2, 2015 Share Posted April 2, 2015 hey i need help here i want to make afk system so that if i both dont click any key and if i dont move my mouse at all for 30 seconds it considers me afk i know how to make this, but it isnt optimized the way i'd do it due to timer resetting alot due to onClientCursorMove event gets 2-3 times more triggered than onClientRender and if im afk and i move my mouse, or press a key, it removes me from afk mode any ideas? Link to comment
Walid Posted April 2, 2015 Share Posted April 2, 2015 why you need to use onClientCursorMove , try to use : getPlayerIdleTime() Link to comment
xTravax Posted April 2, 2015 Author Share Posted April 2, 2015 as stated on wiki that function checks for how long player's position has not been changed by that function i could be considered afk while still moving my mouse around and watching everything that is happening around me Link to comment
Walid Posted April 3, 2015 Share Posted April 3, 2015 it's very simple just try to use your imagination : setTimer() getPlayerIdleTime() -- check if the player idle time > 30 seconds then ..... setElementDimension() -- change the player dimension setElementFrozen() bindKey() unbindKey() etc ... Link to comment
'~DaLesTe^' Posted April 4, 2015 Share Posted April 4, 2015 it's very simple just try to use your imagination : setTimer() getPlayerIdleTime() -- check if the player idle time > 30 seconds then ..... setElementDimension() -- change the player dimension setElementFrozen() bindKey() unbindKey() etc ... addEventHandler("onPlayerSpawn",getRootElement(),rp_Spawn) function PosTime(source) local pos1 = getElementPosition(source) if (pos == pos1) then outputChatBox ( "You entered afk mode To return type: / back", source, 0, 255, 0) setElementFrozen (source, true) setElementDimension (source, 7) setElementData(source, "0", 0) else outputChatBox ( "You moved :c", source, 255, 0, 0) end end function afkGo(source) pos = getElementPosition(source) outputChatBox ( "Wait 5 seconds without moving the character!", source, 0, 255, 0) setTimer(PosTime,5000,1,source) end addCommandHandler('afk', afkGo) function afkExit(source) local away = getElementData(source, "voltar") if (away == 0) then outputChatBox ( "You're back!", source, 0, 255, 0) setElementFrozen (source, false) if getElementDimension(source, 0) then setElementDimension ( source, 0 ) else outputChatBox ( "You are not afk", source, 0, 255, 0) end end end addCommandHandler('back', afkExit) function awayList(source) local connectedPlayers = getElementsByType ( "player" ) for i, aPlayer in ipairs(connectedPlayers) do local afk = getElementData(aPlayer, "afk") if (afk == 1) then outputChatBox ( "tst", source) end end end addCommandHandler('dbug1', awayList) Correct ? 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