onPlayerKeyStateChange

From Liberty Unleashed Wiki
Jump to: navigation, search
Home   |   Squirrel Scripting   |   Server Functions   |   Server Events   |   Client Functions   |   Client Events


This is called when a player presses or stops pressing a certain key.

Syntax

  1. function onPlayerKeyStateChange ( player, key, pressedDown )

Arguments

  • player - The pointer of the player
  • key - The ID of the key in question
  • pressedDown - A boolean representing whether the key was just pressed down or released

Returns

This event does not handle return values.

Example

The following example will annoy the player by noticing them every time they press the 'fire' key.

  1.  
  2. function onPlayerKeyStateChange ( pPlayer, key, down ) {
  3.  
  4. if ( ( key == KEY_ONFOOT_FIRE ) && ( down ) ) MessagePlayer ( "You just pressed <FIRE>.", pPlayer );
  5.  
  6. return;
  7. }
  8.  

Notes

The function MessagePlayer was used in in this example. More info about it in the corresponding page.

Related Events

Personal tools
Namespaces

Variants
Actions
Navigation
scripting
Toolbox