GetMaxPlayers: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
 
(16 intermediate revisions by 10 users not shown)
Line 1: Line 1:
__NOTOC__
__NOTOC__
==Description==
{{Server function}}
This function returns the maximum number of player slots on the server.
This function returns the maximum number of player slots on the server.


Line 6: Line 6:
<syntaxhighlight lang="lua">int getMaxPlayers ()</syntaxhighlight>
<syntaxhighlight lang="lua">int getMaxPlayers ()</syntaxhighlight>


==Required Arguments==
===Returns===
''This function has no arguments.''
Returns the maximum number of players allowed on the server.


==Example==
==Example==
<syntaxhighlight lang="lua">playermax = GetMaxPlayers ()
This example outputs the current number of players together with the maximum number of players when a player joins.
outputChatBox ( "There are currently ", playermax, " player slots in this server." )</syntaxhighlight>
 
<syntaxhighlight lang="lua">
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.
</syntaxhighlight>


==See Also==
==See Also==
{{Player Functions}}
{{Server functions}}

Latest revision as of 18:52, 18 February 2016

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