SetMaxPlayers: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
|||
Line 6: | Line 6: | ||
==Syntax== | ==Syntax== | ||
<syntaxhighlight lang="lua">bool setMaxPlayers ( | <syntaxhighlight lang="lua">bool setMaxPlayers ( int slots )</syntaxhighlight> | ||
===Required Arguments=== | ===Required Arguments=== | ||
Line 19: | Line 19: | ||
This example set server slots count to half value from current value. | This example set server slots count to half value from current value. | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
local curMaxPlayers = getMaxPlayers( | local curMaxPlayers = getMaxPlayers() | ||
local newMaxPlayers = math.ceil( curMaxPlayers / | local newMaxPlayers = math.ceil( curMaxPlayers / 2 ) | ||
setMaxPlayers( newMaxPlayers ) | setMaxPlayers( newMaxPlayers ) |
Revision as of 14:47, 16 December 2014
This function sets the maximum number of player slots on the server.
Note: This function can not set more than <maxplayers> as defined in mtaserver.conf. (To find out the <maxplayers> value, use getServerConfigSetting("maxplayers"))
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