Jump to content

AFK killer


Recommended Posts

function funcInput ( key, keyState )
 
afkTime = 60*2
 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 =600*2
     afktimer = getTimers ( afkTime)
     for timerKey, timerafk in ipairs(afktimer) do
     killTimer ( timerafk )
    end
outputChatBox ( "afk" )
end
 
 
function bindTheKeys ()
 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)

does this work ? if no how to fix :(

Link to comment

u got various syntax problems,i think i fixed it, i also made it little more efficient

afkTime = 1320
 
function funcInput ( key, keyState )
if ( keyState == "up" ) then
if not isTimer(afktimer) then
     afktimer = setTimer(function() outputChatBox("afk") end,afkTime,1)
end
else
killTimer ( afktimer )
end
end
 
function bindTheKeys ()
bindKey ( "forwards", "both", funcInput )
bindKey ( "backwards ", "both", funcInput )
bindKey ( "left", "both", funcInput )
bindKey ( "right", "both", funcInput )
end
 
addEventHandler("onClientPlayerSpawn",getLocalPlayer(),bindTheKeys)

BTW: use




			
				


	Edited  by Guest
	
	

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