From Multi Theft Auto: Wiki
Revision as of 05:56, 11 August 2019 by Danilo (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

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

[[{{{image}}}|link=|]] Note: This function cannot set more than <maxplayers> as defined in mtaserver.conf. (To find out the <maxplayers> value, use getServerConfigSetting("maxplayers"))


bool setMaxPlayers ( int slots )

Required Arguments

  • slots: Maximum number of player slots on the server.


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


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

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

setMaxPlayers( newMaxPlayers )

This example resets the server slots count to the value from mtaserver.conf

setMaxPlayers( tonumber( getServerConfigSetting("maxplayers") ) )

See Also