Scripting/Squirrel/Functions/BindKey: Difference between revisions

From Vice City Multiplayer
Jump to navigation Jump to search
Caution icon
This wiki is using an old backup from 2020
Some information may be old/missing
(How to bind different keys for different actions in game, could be useful, created by Doom_Killer)
 
(Fixed the whole page + some grammar fixes.)
Line 1: Line 1:
'''Syntax'''
== Syntax ==


BindKey( bool:press, key, args..., args2...)
BindKey(press, key, args1, args2)


'''Arguments'''
== Arguments ==


'''bool:press''' This is the bool for the key function to be called once the key is 'pressed' or 'released'.
*''bool'' '''press''' - This is the bool for the key function to be called once the key is 'pressed' or 'released'


'''key''' The key you bind at, you can get key codes from [http://msdn.microsoft.com/en-us/library/windows/desktop/dd375731(v=vs.85).aspx Key Codes]
*''int'' '''key''' - The key you bind it to, you can get the key codes from [http://msdn.microsoft.com/en-us/library/windows/desktop/dd375731(v=vs.85).aspx| here]


'''args...''' You can have this 0.
*''int'' '''args1''' You can set it to 0


'''args2...''' You can have this 0.
*''int'' '''args2''' You can set it to 0


'''Example'''
== Example ==


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


<source lang=squirrel>
<source lang=squirrel>
Line 32: Line 32:
</source>
</source>


'''Notes'''
=== Notes ===


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

Revision as of 17:13, 1 July 2015

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.