Jump to content

AFK kick


MasterTobi

Recommended Posts

You can bind all controls to a function which checks how long ago it has been since the last time the player has pushed a button. If this has been over a certain amount of time (for instance 5 minutes) then you could kick the guy. The detection is best done client-side because of accuracy, but you can also place the checks server-side. (although limited)

- Control names

- bindKey

- onClientRender

- getTickCount

You can check with onClientRender + getTickCount or setTimer how long it has been since the last control was pressed.

------------------

Alternatively, you could of course check if the player position has changed. Should basically require the same procedure, but a little different.

Link to comment

You can bind all controls to a function which checks how long ago it has been since the last time the player has pushed a button. If this has been over a certain amount of time (for instance 5 minutes) then you could kick the guy. The detection is best done client-side because of accuracy, but you can also place the checks server-side. (although limited)

- Control names

- bindKey

- onClientRender

- getTickCount

You can check with onClientRender + getTickCount or setTimer how long it has been since the last control was pressed.

------------------

Alternatively, you could of course check if the player position has changed. Should basically require the same procedure, but a little different.

Link to comment

spezial thx

my afk code is this :

function funcInput ( key, keyState )
 
afkTime =60000*15
 if ( keyState == "up" ) then
   setTimer(afkgo,afkTime,1)
 end
 
if ( keyState == "down" ) then
	afktimer = getTimers ( afkTime)
	for timerKey, timerafk in ipairs(afktimer) do
     killTimer ( timerafk )
  end
end
 
end
 
function afkgo()
afkTime =60000*15
	afktimer = getTimers ( afkTime)
	for timerKey, timerafk in ipairs(afktimer) do
     killTimer ( timerafk )
  end
outputChatBox ( "afk" )
end
 
 
function bindTheKeys ()
outputChatBox("jupp")
 bindKey ( "forwards", "down", funcInput )
 bindKey ( "forwards", "up", funcInput )
 bindKey ( "backwards ", "down", funcInput )
 bindKey ( "backwards ", "up", funcInput )
 bindKey ( "left", "down", funcInput )
 bindKey ( "left", "up", funcInput )
 bindKey ( "right", "down", funcInput )
 bindKey ( "right", "up", funcInput )
 
 
end
addEventHandler("onClientPlayerSpawn",getLocalPlayer(),bindTheKeys)

i hopp it is good :P

you were kicked after 15mins if you not move

edit: you have to write your kick command in the function afkgo() xD

Link to comment

spezial thx

my afk code is this :

function funcInput ( key, keyState ) afkTime =60000*15  if ( keyState == "up" ) then    setTimer(afkgo,afkTime,1)  end 	if ( keyState == "down" ) then		afktimer = getTimers ( afkTime)		for timerKey, timerafk in ipairs(afktimer) do      killTimer ( timerafk )	  end	end end function afkgo()afkTime =60000*15		afktimer = getTimers ( afkTime)		for timerKey, timerafk in ipairs(afktimer) do      killTimer ( timerafk )	  endoutputChatBox ( "afk" )end  function bindTheKeys ()outputChatBox("jupp")  bindKey ( "forwards", "down", funcInput )  bindKey ( "forwards", "up", funcInput )  bindKey ( "backwards ", "down", funcInput )  bindKey ( "backwards ", "up", funcInput )  bindKey ( "left", "down", funcInput )  bindKey ( "left", "up", funcInput )  bindKey ( "right", "down", funcInput )  bindKey ( "right", "up", funcInput )  endaddEventHandler("onClientPlayerSpawn",getLocalPlayer(),bindTheKeys)

i hopp it is good :P

you were kicked after 15mins if you not move

edit: you have to write your kick command in the function afkgo() xD

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