OnKeyDown

From Vice City Multiplayer
Revision as of 18:33, 16 March 2016 by Decent 946 (talk | contribs) (Created page with "__NOTOC__ This function allows the server to inform the player, that he pressed the key and and the key works like a command. == Syntax == <pre>function onKeyDown( player, k...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
Caution icon
This wiki is using an old backup from 2020
Some information may be old/missing

This function allows the server to inform the player, that he pressed the key and and the key works like a command.

Syntax

function onKeyDown( player, key )

Parameters

  • Player player - The player who presses the key.
  • key - The key player presses.


Example

In this function i have chosen key "ENTER". When a player will press the key/button 'enter' it will inform the server that the player pressed the key. And the server will perform the work like a Command.

function onScriptLoad()
{
	enter <- BindKey( true, 0x0D, 0, 0 );  // The Key Code of enter is 0x0D . we will use bindkey function to set the key. And it is required.
}

function onKeyDown( player, key )
{
	if ( key == enter )
	{
		PrivMessage( player, "you Successfully pressed the Key Enter." );
	}
}

Notes

Function PrivMessage and function BindKey were used in this example.

you can Find the key codes [here]

Related Events