Jump to content

Trouble


Recommended Posts

Posted

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) 

If you're looking for a cheap paid scripter, don't hesitate to contact me.

Great minds discuss ideas, Average minds discuss events and small minds discuss people.

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

If you're looking for a cheap paid scripter, don't hesitate to contact me.

Great minds discuss ideas, Average minds discuss events and small minds discuss people.

Posted

Anyone? Or just give me functions/events i could use to check when the player move cursor and press a key.

If you're looking for a cheap paid scripter, don't hesitate to contact me.

Great minds discuss ideas, Average minds discuss events and small minds discuss people.

Posted

I don't really understand the problem.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

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.

If you're looking for a cheap paid scripter, don't hesitate to contact me.

Great minds discuss ideas, Average minds discuss events and small minds discuss people.

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