SetMaxPlayers

From Multi Theft Auto: Wiki
Revision as of 11:19, 16 December 2014 by Glossy (talk | contribs) (→‎Example)
Jump to navigation Jump to search

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 ( 50 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(50)
local newMaxPlayers = math.ceil( curMaxPlayers / 50 )

setMaxPlayers( newMaxPlayers )


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

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

See Also