SetMaxPlayers: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 28: Line 28:
This example resets the server slots count to the value from mtaserver.conf
This example resets the server slots count to the value from mtaserver.conf
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
setMaxPlayers( getServerConfigSetting("maxplayers") )
setMaxPlayers( tonumber( getServerConfigSetting("maxplayers") ) )
</syntaxhighlight>
</syntaxhighlight>


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

Revision as of 02:49, 23 January 2013

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

Note: This function can not 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