# toggleAllControls (Server)

> Turns all of a player's controls on or off at once. The order goes to their client.

- **Platform**: MY Multiplayer (MYMP)
- **Kind**: Lua Function
- **Side**: Server
- **Category**: Controls
- **URL**: https://wiki.mymp.gg/en/toggleAllControls-server
- **Counterpart**: Also exists on the client, with its own implementation: [toggleAllControls (Client)](https://wiki.mymp.gg/en/toggleAllControls-client.md)

## Syntax

```lua
bool toggleAllControls(player thePlayer, bool enabled [, bool gtaControls = true, bool mtaControls = true])
```

## Parameters

| Name | Type | Description |
| --- | --- | --- |
| `thePlayer` | `player` | The player. |
| `enabled` | `bool` | `true` to turn them on, `false` to turn them off. |
| `gtaControls` | `bool` | Whether it applies to the game's controls, such as walking, shooting and driving. The server keeps this state for `isControlEnabled`. *(default: `true`)* |
| `mtaControls` | `bool` | Whether it applies to the keys the client bound to commands with `bindKey`. While off, those keys do not run their command. *(default: `true`)* |

## Returns

`true` if the order was sent. `false` if the element is not a player.

## Example

```lua
addEventHandler("onPlayerSpawn", root, function()
    toggleAllControls(source, false)
    setTimer(toggleAllControls, 3000, 1, source, true)
end)
```

## See also

- [toggleControl (Server)](https://wiki.mymp.gg/en/toggleControl-server.md): Turns one of a player's controls on or off. Their client stops passing that control to the game, even with its key held down.
- [isControlEnabled (Server)](https://wiki.mymp.gg/en/isControlEnabled-server.md): Tells whether one of a player's controls is on, going by what the server sent to their client.
- [toggleAllControls (Client)](https://wiki.mymp.gg/en/toggleAllControls-client.md): Turns all of the local player's controls on or off at once.
