GetMaxPlayers: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 3: | Line 3: | ||
==Syntax== | ==Syntax== | ||
<section name="Server" class="server"> | |||
<syntaxhighlight lang="lua">int getMaxPlayers ()</syntaxhighlight> | <syntaxhighlight lang="lua">int getMaxPlayers ()</syntaxhighlight> | ||
===Returns=== | ===Returns=== | ||
Returns the maximum number of players allowed on the server. | Returns the maximum number of players allowed on the server. | ||
</section> | |||
==Example== | ==Example== |
Revision as of 12:29, 3 August 2007
This function returns the maximum number of player slots on the server.
Syntax
Click to expand [+]
ServerExample
This example outputs the current number of players together with the maximum number of players when a player joins.
function showPlayers() local maxPlayers = getMaxPlayers() -- get maximum number of players on the server local players = getElementsByType("player") -- get a table of all current players outputChatBox("There are "..#players.."/"..maxPlayers.." players playing",source) -- output a message to the joining player end addEventHandler("onPlayerJoin",getRootElement(),showPlayers) -- add the Event for "onPlayerJoin" that will call the "showPlayers" function
See Also
- getMaxPlayers
- getServerConfigSetting
- getServerHttpPort
- getServerName
- getServerPassword
- getServerPort
- isGlitchEnabled
- setGlitchEnabled
- setMaxPlayers
- setServerConfigSetting
- setServerPassword
- shutdown