onPlayerCommand

From Liberty Unleashed Wiki
Revision as of 17:02, 10 November 2013 by XaMaX (Talk | contribs)

Jump to: navigation, search
Home   |   Squirrel Scripting   |   Server Functions   |   Server Events   |   Client Functions   |   Client Events

This is called when a player press a GTA's control keys.

Syntax

  1. function onPlayerKeyStateChange ( Player player, OldKeys, NewKeys )

Arguments

  • player - The pointer of the player
  • OldKeys - The last known keys pressed by the player
  • NewKeys - The new key states

Returns

This event does not handle return values.

Example

This example detects whether the fire key was pressed

  1.  
  2. function onPlayerKeyStateChange ( pPlayer, oldkeys, newkeys ) {
  3.  
  4. if ( ( oldkeys & KEY_ONFOOT_FIRE == 0 ) && ( newkeys & KEY_ONFOOT_FIRE != 0 ) )
  5. {
  6. MessagePlayer ( "Fire key pressed", pPlayer );
  7. }
  8.  
  9. return;
  10. }
  11.  

Notes

The functions MessagePlayer and Player.Pos were used in this example. More info about them can be found in the corresponding pages.

Related Events

Personal tools
Namespaces

Variants
Actions
Navigation
scripting
Toolbox