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...") |
m (example fix) |
||
Line 19: | Line 19: | ||
addEventHandler( "onPlayerConnect", root, | addEventHandler( "onPlayerConnect", root, | ||
function() | function() | ||
local nowPlayers = | local nowPlayers = getPlayerCount() | ||
local maxPlayers = getMaxPlayers() | local maxPlayers = getMaxPlayers() | ||
if nowPlayers and maxPlayers and | if nowPlayers and maxPlayers and nowPlayers >= maxPlayers then | ||
setMaxPlayers( maxPlayers + 1 ) | setMaxPlayers( maxPlayers + 1 ) | ||
end | end |
Revision as of 18:41, 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( "onPlayerConnect", 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