GetMaxPlayers: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
Jack Johnson (talk | contribs) m (Shortened down the code) |
||
Line 13: | Line 13: | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
function showPlayers() | function showPlayers() | ||
outputChatBox("There are "..getPlayerCount().."/"..getMaxPlayers().." players playing.",source) --output a message to the joined player informing the player count and max players. | |||
outputChatBox("There are " .. | |||
end | end | ||
addEventHandler("onPlayerJoin", | addEventHandler("onPlayerJoin",root,showPlayers) --Add an event handler to call the function when a player joins. | ||
</syntaxhighlight> | </syntaxhighlight> | ||
==See Also== | ==See Also== | ||
{{Server functions}} | {{Server functions}} |
Revision as of 12:56, 14 January 2015
This function returns the maximum number of player slots on the server.
Syntax
int getMaxPlayers ()
Returns
Returns the maximum number of players allowed on the server.
Example
This example outputs the current number of players together with the maximum number of players when a player joins.
function showPlayers() outputChatBox("There are "..getPlayerCount().."/"..getMaxPlayers().." players playing.",source) --output a message to the joined player informing the player count and max players. end addEventHandler("onPlayerJoin",root,showPlayers) --Add an event handler to call the function when a player joins.
See Also
- getMaxPlayers
- getServerConfigSetting
- getServerHttpPort
- getServerName
- getServerPassword
- getServerPort
- isGlitchEnabled
- setGlitchEnabled
- setMaxPlayers
- setServerConfigSetting
- setServerPassword
- shutdown