GetPlayerCount

From Multi Theft Auto: Wiki
Revision as of 16:00, 19 August 2007 by Arc (talk | contribs)
Jump to navigation Jump to search

This function returns the number of players currently connected to the server.

Syntax

int getPlayerCount ( )

Returns

Returns the number of players connected to the server as an int.

Example

This example displays a chat message with the number of players connected to the server when a player joins or quits.

function playerCount ( )
	outputChatBox ( "There are now " .. getPlayerCount() .. " players on this server!" )
end
addEventHandler ( "onPlayerJoin", getRootElement(), playerCount )
addEventHandler ( "onPlayerQuit", getRootElement(), playerCount )

See Also