# setMaxPlayers (Server)

> Changes how many players the server takes at once.

- **Platform**: MY Multiplayer (MYMP)
- **Kind**: Lua Function
- **Side**: Server
- **Category**: Players and accounts
- **URL**: https://wiki.mymp.gg/en/setMaxPlayers

## Syntax

```lua
bool setMaxPlayers(int max)
```

## Parameters

| Name | Type | Description |
| --- | --- | --- |
| `max` | `int` | The new limit, from 0 up to the `players` convar's value. |

## Returns

`true` if the limit changed, `false` if it is above the `players` convar the server started with.

## Example

```lua
addCommandHandler("maintenance", function()
    setMaxPlayers(getPlayerCount())
end)
```

### Note

The limit cannot rise above the `players` convar read when the server started.

## See also

- [getMaxPlayers (Server)](https://wiki.mymp.gg/en/getMaxPlayers.md): Returns how many players the server takes at once.
- [getPlayerCount (Server)](https://wiki.mymp.gg/en/getPlayerCount.md): Returns how many players are on the server.
