SetMaxPlayers: Difference between revisions
Jump to navigation
Jump to search
(Created page with "__NOTOC__ {{Server function}} This function set the maximum number of player slots on the server. ==Syntax== <syntaxhighlight lang="lua">bool setMaxPlayers ( int slots )</syntaxhighlight> ===Required Argu...") |
mNo edit summary |
||
(14 intermediate revisions by 7 users not shown) | |||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
{{Server function}} | {{Server function}} | ||
This function | This function sets the maximum number of player slots on the server. | ||
{{Note|This function cannot set more than <maxplayers> as defined in [[mtaserver.conf]]. (To find out the <maxplayers> value, use getServerConfigSetting("maxplayers"))}} | |||
==Syntax== | ==Syntax== | ||
Line 15: | Line 16: | ||
==Example== | ==Example== | ||
This example | This example set server slots count to half value from current value. | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
local curMaxPlayers = getMaxPlayers() | |||
local newMaxPlayers = math.ceil( curMaxPlayers / 2 ) | |||
setMaxPlayers( newMaxPlayers ) | |||
</syntaxhighlight> | |||
This example resets the server slots count to the value from mtaserver.conf | |||
<syntaxhighlight lang="lua"> | |||
setMaxPlayers( tonumber( getServerConfigSetting("maxplayers") ) ) | |||
</syntaxhighlight> | |||
==See Also== | ==See Also== | ||
{{Server functions}} | {{Server functions}} |
Latest revision as of 05:56, 11 August 2019
This function sets the maximum number of player slots on the server.
Syntax
bool setMaxPlayers ( int slots )
Required Arguments
- slots: Maximum number of player slots on the server.
Returns
Returns true if number of player slots was successfully changed, false or nil otherwise.
Example
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
- getMaxPlayers
- getServerConfigSetting
- getServerHttpPort
- getServerName
- getServerPassword
- getServerPort
- isGlitchEnabled
- setGlitchEnabled
- setMaxPlayers
- setServerConfigSetting
- setServerPassword
- shutdown