- Documentation
- Server functions
- setControlState
Function
setControlState
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.
statebooltrue= 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)