GetMaxPlayers

From Multi Theft Auto: Wiki
Revision as of 23:20, 14 August 2007 by Xanarki (talk | contribs) (→‎Example)
Jump to navigation Jump to search

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

Click to collapse [-]
Server

This example outputs the current number of players together with the maximum number of players when a player joins.

function showPlayers()
	local maxPlayers = getMaxPlayers() -- get maximum number of players on the server
	local players = getElementsByType("player") -- get a table of all current players
	outputChatBox("There are "..#players.."/"..maxPlayers.." players playing",source) -- output a message to the joining player
end
addEventHandler("onPlayerJoin",getRootElement(),showPlayers) -- add the Event for "onPlayerJoin" that will call the "showPlayers" function

See Also