Jump to content

Trouble


Recommended Posts

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

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

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