Thread: onKeyPressed()
View Single Post
  #8  
Old 08-21-2009, 07:42 PM
Gambet Gambet is offline
Registered User
Join Date: Oct 2003
Posts: 2,712
Gambet is on a distinguished road
Quote:
Originally Posted by DustyPorViva View Post
PHP Code:
function onKeyPressed() {
  if (
keydown(0-3)) {
    
player.chat "arrow key pressed";
  }

keydown(int) can be used along with onKeyPressed() to detect default key configurations.

That's a bit vague for someone that might not be familiar with loops since they wouldn't realize that they would benefit from using one in this case:

PHP Code:
function onKeyPressed() {
  for (
temp.key 0temp.key 4temp.key++) {
    if (
keydown(key)) {
      
player.chat "directional key pressed";
    }
  }


Stuff like this has been posted before, possibly in multiple threads, people should really use the search function, they would get answers to their questions much faster.


EDIT: It's probably better to say 'directional key pressed' instead of 'arrow key pressed' since that would imply that the script would only trigger when you press an arrow key, when in fact it would trigger whenever you pressed any of the directional keys that you have set in your F3 options.

Last edited by Gambet; 08-21-2009 at 08:02 PM..
Reply With Quote