GetPlayerCount

Category: Player
Since engine version: 1.0 OC

Description

Returns the number of players currently in the game.

Syntax

int GetPlayerCount(int player_type);

Parameter

player_type:
[opt] If specified, only the number of players of the specified type is returned. For a list of all player types see GetPlayerType.

Remark

As players may join and leave a game at runtime, there can be "gaps" in player indexing, meaning player numbers may skip certain values. GetPlayerCount returns the actual number of players, not the index of the last player plus one. To process all joined players you need special handling (see example) - you cannot simply run from index 0 to GetPlayerCount() - 1. See the example for GetPlayerByIndex.

Example

See also: EliminatePlayer, GetPlayerByIndex, GetPlayerName, GetStartupPlayerCount
Sven2, 2007-12