Jump to content

afk script


xTravax

Recommended Posts

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

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
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

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...