setMaxPlayers | Multi Theft Auto: Wiki Skip to content

setMaxPlayers

Client-side
Server-side
Shared

Manual Review Required

Please finish this page using the corresponding Old Wiki article. Go to Contribution guidelines for more information.


This function sets the maximum number of player slots on the server.

Note

This function cannot set more than as defined in mtaserver.conf . (To find out the value, use getServerConfigSetting("maxplayers"))

Syntax

bool setMaxPlayers ( int slots )
Required Arguments
  • slots: Maximum number of player slots on the server.

Returns

  • bool: value

Returns true if number of player slots was successfully changed, false or nil otherwise.

Code Examples

shared

This example set server slots count to half value from current value.

local curMaxPlayers = getMaxPlayers()
local newMaxPlayers = math.ceil( curMaxPlayers / 2 )
setMaxPlayers( newMaxPlayers )