Scripting/Squirrel/Functions/Player.GameKeys

From Vice City Multiplayer
Jump to navigation Jump to search

This function will inform you the ID(s) of they keys that player has pressed at the current moment.

-> This function is triggered whenever a player presses any key of keyboard.

--> It can also be used to check ID of any key of the keyboard in vcmp.

Note: Each keyborad key has its different gamekey ID.

Syntax

player.GameKeys player.GameKeys = ID(s)

Parameterand result

ID(s) of the Key pressed.

Example

In this Example, We are going to check Which key(s) are being pressed by the specified user at the current moment ( at the time of use of command ).

function onPlayerCommand( player, cmd, text )
{
  if ( cmd == "getkeys" )
  {
    if ( text == null ) PrivMessage( player, "SYNTAX: /getkeys < player ID >" );
    else if ( !IsNum(text) ) PrivMessage( player, "Error - Please Sepcify player's ID" ); //ID selects the distnict player.
    else
    {
      local plr = FindPlayer( text.tointeger() );
      
      if ( !plr ) PrivMessage( player, "No such player..." );
      else
      {
         MessagePlayer( "The ID(s) of the keys "+plr+" is pressing: "+plr.GameKeys, player );
      }
    }
  }

}


Notes

Call onPlayerCommand, functions FindPlayer, PrivMessage and MessagePlayer were used in this example


Related Functions

Player Game Functions

These functions exist for compatibility with the R2 Squirrel server.