MasterTobi Posted January 27, 2010 Share Posted January 27, 2010 hm hey i need a function or event, those examines whether client itself moved or has anybody an afk-kicker ? thx sry for my ***** english i understand english very good, but writing OMG Link to comment
MasterTobi Posted January 27, 2010 Author Share Posted January 27, 2010 hm hey i need a function or event, those examines whether client itself moved or has anybody an afk-kicker ? thx sry for my ***** english i understand english very good, but writing OMG Link to comment
Gamesnert Posted January 27, 2010 Share Posted January 27, 2010 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
Gamesnert Posted January 27, 2010 Share Posted January 27, 2010 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
MasterTobi Posted January 27, 2010 Author Share Posted January 27, 2010 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 you were kicked after 15mins if you not move edit: you have to write your kick command in the function afkgo() Link to comment
MasterTobi Posted January 27, 2010 Author Share Posted January 27, 2010 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 you were kicked after 15mins if you not move edit: you have to write your kick command in the function afkgo() Link to comment
subenji99 Posted January 27, 2010 Share Posted January 27, 2010 Quick note - this code will kick anyone that plays with a gamepad and uses an analog stick for input. https://wiki.multitheftauto.com/wiki/Get ... ntrolState Link to comment
subenji99 Posted January 27, 2010 Share Posted January 27, 2010 Quick note - this code will kick anyone that plays with a gamepad and uses an analog stick for input. https://wiki.multitheftauto.com/wiki/Get ... ntrolState Link to comment
Gamesnert Posted January 27, 2010 Share Posted January 27, 2010 Quick note - this code will kick anyone that plays with a gamepad and uses an analog stick for input.https://wiki.multitheftauto.com/wiki/Get ... ntrolState Kind of an unrelated question but, why would you want to kick players because they have a gamepad? Link to comment
Gamesnert Posted January 27, 2010 Share Posted January 27, 2010 Quick note - this code will kick anyone that plays with a gamepad and uses an analog stick for input.https://wiki.multitheftauto.com/wiki/Get ... ntrolState Kind of an unrelated question but, why would you want to kick players because they have a gamepad? Link to comment
robhol Posted January 27, 2010 Share Posted January 27, 2010 Quick note - this code will kick anyone that plays with a gamepad and uses an analog stick for input.https://wiki.multitheftauto.com/wiki/Get ... ntrolState Kind of an unrelated question but, why would you want to kick players because they have a gamepad? Not what he said, he just pointed it out. Link to comment
robhol Posted January 27, 2010 Share Posted January 27, 2010 Quick note - this code will kick anyone that plays with a gamepad and uses an analog stick for input.https://wiki.multitheftauto.com/wiki/Get ... ntrolState Kind of an unrelated question but, why would you want to kick players because they have a gamepad? Not what he said, he just pointed it out. Link to comment
subenji99 Posted January 27, 2010 Share Posted January 27, 2010 Indeed, I was saying that a player that uses a gamepad will be sending AnalogState's, not the usual digital inputs. Therefore this code will not see any input, and will kick an active player. 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