Scripting/Squirrel/Functions/BindKey

From Vice City Multiplayer
Revision as of 14:00, 3 August 2015 by ProsuWANTED (talk | contribs)
Jump to navigation Jump to search
Caution icon
This wiki is using an old backup from 2020
Some information may be old/missing

Syntax

BindKey(press, key, args1, args2)

Arguments

  • bool press - This is the bool for the key function to be called once the key is 'pressed' or 'released'
  • int key - The key you bind it to, you can get the key codes from here
  • int args1 You can set it to 0
  • int args2 You can set it to 0

Example

The following example will bind the left-shift key for a player and will send him a message when he player presses that key:

function onScriptLoad()
{
    lshift <- BindKey(true, 0xA0, 0, 0);
}

function onKeyDown( player, key )
{
    if( key == lshift )
    {
        MessagePlayer( ">> You pressed the left shift key", player );
    }
}

Notes

Call onScriptLoad and onKeyDown were used in this example. More info about them in the corresponding pages.