Scripting/Squirrel/Events/Player/onPlayerKeyStateChange

From VC-MP Wiki

Jump to: navigation, search

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

Syntax

function onPlayerKeyStateChange( player, key, pressedDown )

Parameters

  • 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

Example

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

function onPlayerKeyStateChange( player, key, down )
{
     if ( ( key == KEY_ONFOOT_FIRE ) && ( down ) )
          MessagePlayer( "You just pressed <FIRE>.", player );
}

Notes

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

Related Events

Personal tools
squirrel scripting