- Documentation
- Input and controls
Category
Input and controls
All Lua functions and events in the Input and controls category, on the server and the client.
Server functions 7
getReturns the keys a player has bound to commands (Bound Keys bindKeywith a command name) as a key -> command table.getReturns the server's built-in commands, the ones no resource adds (e.g.Builtin Commands me,pm,kick). With a player it returns only the commands that player may use according toadmins.xml. Useful for a custom chat that recognises commands itself.getReturns the names of commands registered by a resource, or by every resource without an argument.Command Handlers getReturns the commands bound to a player's key.Commands Bound To Key getReturns the control state set withControl State setControlState.getReturns the first key a player has bound to a command.Key Bound To Command setPresses or releases a game control for a player, as if they held the key (e.g.Control State acceleratespeeds up the car,forwardswalks forward). The state lasts until you change it.
Client functions 11
createShows a Windows system notification next to the clock (useful when the game is minimised). In the current client version the function is not wired to the game yet and returnsTray Notification falsewith a console warning;isTrayNotificationEnabledtells whether it works already.executeSends a command to the server as if the player typed it in chat (without the leading slash).Command getReturns the player's keyboard layout (name and identifier). In the current client version the function is not wired to the game yet and returnsKeyboard Layout falsewith a console warning.getChecks whether a key is held down right now. Works withoutKey State bindKeytoo, e.g. inonClientRender.getReturns the player's language (the same one chosen in the launcher and game settings) as a table with a code and a name. Codes:Localization pl,en,de,es,fr,it,pt,ru,uk,tr,cs,ro. The server knows the same language throughgetPlayerLocalization.isChecks whether Caps Lock is on (e.g. to warn while typing a password).Caps Lock Enabled isChecks whether the F11 key minimises the game. ReturnsMinimize Key Enabled falsewhen any resource turned it off withsetMinimizeKeyEnabled.isChecks whether the client supports system notifications (Tray Notification Enabled createTrayNotification). It returnsfalsein the current version.setPuts text into the player's system clipboard (e.g. an invite code or a server address). In the current client version the function is not wired to the game yet and returnsClipboard falsewith a console warning.setTurns minimising the game with the F11 key on or off. When it is off, F11 does not minimise the game but still works inMinimize Key Enabled bindKey, so the server can bind its own function to it (e.g. a custom map).setFlashes the game icon on the taskbar, e.g. when the player got a private message while the window is in the background. In the current client version the function is not wired to the game yet and returnsWindow Flashing falsewith a console warning.
Shared functions 14
addRegisters a chat and console command (e.g.Command Handler /car). When a player types it, the function is called. On the server the function gets the player, the command name and the following words as separate arguments; on the client the command name and the words. One command can have several functions, also from different resources. The command goes away with the resource that added it.bindBinds a function or a command to a player's key. The function gets (on the server also the player) the key name, the state and the extra arguments fromKey bindKey. Instead of a function you can pass a command name: the key runs it like/command. On the server the player's game watches the key and reports presses to the server.executeRuns a command registered withCommand Handler addCommandHandleras if a player typed it. On the server you pass a player (ornil) and the arguments: a single string is split into words like in chat. On the client it runs client commands.getTells whether a control belongs to walking (Control Group "foot") or to a vehicle ("vehicle").getReturns the game control names accepted byControl Names toggleControl,setControlStateandisControlEnabled.getReturns the functions (and command names) bound to a key.Functions Bound To Key getReturns the first key a function is bound to.Key Bound To Function isChecks whether a game control is enabled (not blocked withControl Enabled toggleControlortoggleAllControls).isChecks whether a function is bound to a key (a specific one or any).Key Bound isChecks whether a control name is known to the game.Valid Control Name removeRemoves a command added withCommand Handler addCommandHandler. With a function it removes only that handler; without one it removes every handler of the command.toggleEnables or disables all game controls at once (e.g. during a cutscene or when freezing a player). Chat, console andAll Controls bindKeykeys keep working.toggleEnables or disables one game control, e.g. shooting (Control fire), jumping (jump) or entering vehicles (enter_exit). A disabled control ignores the player's keys. On the server you pass a player orroot.unbindUnbinds a function or a command from a key. Without a function it removes everything from the key in that state, and without a state in both states.Key
Server events 2
Client events 3
onThe player typed a character (a letter respecting the keyboard layout and accented characters). For your own text fields drawn withClient Character dx.onThe player clicked the mouse with the cursor visible (outside GUI windows).Client Click onThe player pressed or released a key. The event sees every key, including the ones the game uses.Client Key