onClientKeyStateChange

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

This event is called when the local players key states change.

Syntax

  1. function onClientKeyStateChange( oldkeys, newkeys )

Arguments

  • oldkeys - The last known keys pressed by the player
  • newkeys - The new key states

Returns

This event does not handle return values.

Example

The following example will kill the player when they shoot

  1.  
  2. function onClientKeyStateChange( oldKeys, newKeys )
  3. {
  4. if ( newKeys & KEY_ONFOOT_FIRE )
  5. {
  6. local plr = FindLocalPlayer();
  7. // We dont want the player to shoot, so kill the sucker!
  8. Message( "You are not allowed to shoot here, so die!" );
  9. plr.Health = 0;
  10. }
  11. }
  12.  

Notes

The commands Message, FindLocalPlayer and Player.Health was used in in this example. More info about these in the corresponding pages.

Related Events

Personal tools
Namespaces

Variants
Actions
Navigation
scripting
Toolbox