SetMaxPlayers: Difference between revisions
Jump to navigation
Jump to search
m (example fix) |
m (example fix 2) |
||
Line 17: | Line 17: | ||
This example increases server slots count if server is full. | This example increases server slots count if server is full. | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
addEventHandler( " | addEventHandler( "onPlayerJoin", root, | ||
function() | function() | ||
local nowPlayers = getPlayerCount() | local nowPlayers = getPlayerCount() |
Revision as of 19:07, 3 September 2011
This function set 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 increases server slots count if server is full.
addEventHandler( "onPlayerJoin", root, function() local nowPlayers = getPlayerCount() local maxPlayers = getMaxPlayers() if nowPlayers and maxPlayers and nowPlayers >= maxPlayers then setMaxPlayers( maxPlayers + 1 ) end end )
See Also
- getMaxPlayers
- getServerConfigSetting
- getServerHttpPort
- getServerName
- getServerPassword
- getServerPort
- isGlitchEnabled
- setGlitchEnabled
- setMaxPlayers
- setServerConfigSetting
- setServerPassword
- shutdown