Jump to content

Pressing keys on the keyboard


Guest TcCc

Recommended Posts

Posted

is there a function for this? like if a person pressed a key it would do something.

Posted

no i mean like a server function where if some on pressed a it would send them a message.

Posted

bindKey does this for you.

Wiki: http://development.mtasa.com/index.php?title=bindKey

Code example which says "Hello" to them when they press F5

  
function playerF5Down ( playerElement, key, state ) 
  outputChatBox ( "Hello", playerElement ) 
end 
  
function onPlayerJoin() 
  bindKey ( source, "F5", "down", playerF5Down ) 
end 
addEventHandler ( "onPlayerJoin", getRootElement(), onPlayerJoin ) 
  

(This code is untested and might not work, if it does not work then get back to me)

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