SetMaxPlayers: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
mNo edit summary
mNo edit summary
 
(7 intermediate revisions by 4 users not shown)
Line 2: Line 2:
{{Server function}}
{{Server function}}
This function sets the maximum number of player slots on the server.
This function sets the maximum number of player slots on the server.
 
{{Note|This function cannot set more than <maxplayers> as defined in [[mtaserver.conf]]. (To find out the <maxplayers> value, use getServerConfigSetting("maxplayers"))}}
'''Note''': the maximum this function can set is what is defined in mtaserver.conf


==Syntax==
==Syntax==
Line 23: Line 22:


setMaxPlayers( newMaxPlayers )
setMaxPlayers( newMaxPlayers )
</syntaxhighlight>
This example resets the server slots count to the value from mtaserver.conf
<syntaxhighlight lang="lua">
setMaxPlayers( tonumber( getServerConfigSetting("maxplayers") ) )
</syntaxhighlight>
</syntaxhighlight>


==See Also==
==See Also==
{{Server functions}}
{{Server functions}}

Latest revision as of 05:56, 11 August 2019

This function sets the maximum number of player slots on the server.

[[{{{image}}}|link=|]] Note: This function cannot set more than <maxplayers> as defined in mtaserver.conf. (To find out the <maxplayers> value, use getServerConfigSetting("maxplayers"))

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 set server slots count to half value from current value.

local curMaxPlayers = getMaxPlayers()
local newMaxPlayers = math.ceil( curMaxPlayers / 2 )

setMaxPlayers( newMaxPlayers )


This example resets the server slots count to the value from mtaserver.conf

setMaxPlayers( tonumber( getServerConfigSetting("maxplayers") ) )

See Also