-.Paradox.- Posted July 2, 2014 Share Posted July 2, 2014 Hello guys, I'm trying to make an Away From Keyboard script for my multi-gamemode race server, In a running gamemode if player didn't move for exactly 1 minute he get kicked and i'm trying to cancel it if he moved before 1 min passes, anyway here is the code. function checkSomething() if getElementData(thePlayer, "Away From Keyboard") == true then setElementData(thePlayer, "Away From Keyboard", false) end end addEventHandler("onClientKey", getRootElement(), checkSomething) addEventHandler( "onClientCursorMove", getRootElement(), checkSomething) Link to comment
xXMADEXx Posted July 2, 2014 Share Posted July 2, 2014 You can just use it on the server-side with getPlayerIdleTime function checkPlayers ( ) for i, p in pairs ( getElementsByType ( "player" ) ) do local t = math.floor ( getPlayerIdleTime ( p ) / 1000 ) if ( t >= 60 ) then kickPlayer ( p ) end end end checkPlayers ( ) setTimer ( checkPlayers, 3000, 0 ) Link to comment
-.Paradox.- Posted July 2, 2014 Author Share Posted July 2, 2014 You can just use it on the server-side with getPlayerIdleTime function checkPlayers ( ) for i, p in pairs ( getElementsByType ( "player" ) ) do local t = math.floor ( getPlayerIdleTime ( p ) / 1000 ) if ( t >= 60 ) then kickPlayer ( p ) end end end checkPlayers ( ) setTimer ( checkPlayers, 3000, 0 ) I did it already with getPlayerIdleTime in Server side and i set his element Data to "Away From Keyboard", in the client side i wanted to use onClientKey and onClientCursorMove to check if his ElementData is Away From Keyboard then set it to false... Link to comment
-.Paradox.- Posted July 3, 2014 Author Share Posted July 3, 2014 Anyone? Or just give me functions/events i could use to check when the player move cursor and press a key. Link to comment
Castillo Posted July 5, 2014 Share Posted July 5, 2014 I don't really understand the problem. Link to comment
-.Paradox.- Posted July 5, 2014 Author Share Posted July 5, 2014 Sorry for being unclear, I'm trying to set racer ElementData (Away From Keyboard) to false after moving his curosr or clicking a key, thanks. Link to comment
SkittlesAreFalling Posted July 5, 2014 Share Posted July 5, 2014 (edited) localPlayer or getLocalPlayer() instead of thePlayer Edited July 5, 2014 by Guest Link to comment
MTA Team botder Posted July 5, 2014 MTA Team Share Posted July 5, 2014 getRootElement() Predefined variable: root getLocalPlayer() Predefined variable: localPlayer Source: https://forum.multitheftauto.com/viewtopic.php?f=91&t=39678 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