ServersYour serverFor creatorsForumFAQDocumentationSecurity
Download the launcher
  1. Documentation
  2. Server functions
  3. setControlState

Function

setControlState

ServerInput and controlsIdentical to MTA:SA

Presses or releases a game control for a player, as if they held the key (e.g. accelerate speeds up the car, forwards walks forward). The state lasts until you change it.

Syntax

bool setControlState(player thePlayer, string control, bool state)

Arguments

thePlayerplayer
The player.
controlstring
The control name.
statebool
true = pressed, false = released.

Returns

true on success.

Example

The /cruise command holds the throttle for the player.

addCommandHandler("tempomat", function(player)
    setControlState(player, "accelerate", not getControlState(player, "accelerate"))
end)

See also