# GetPlayerByIndex

Player
5.1 OC
int
int index Index in the player table.
int player_type If specified, the indicated player of the specified type is returned. This can be used e.g. to walk only through the list of human players or only through the list of script players. For a list of all player types see GetPlayerType.
Returns the indicated player number. This function guarantees that for values from 0 to GetPlayerCount()-1 a valid player number will be returned (notice that there may be "gaps" between player numbers in case some players have left the game). This makes it easier to process all players in a loop.
for
(var i = 0; i < GetPlayerCount(); i++) Log("Moin, %s", GetPlayerName(GetPlayerByIndex(i)));
Welcomes all players in the log file.
for
(var i = 0; i < GetPlayerCount(C4PT_User); i++) EliminatePlayer(GetPlayerByIndex(i, C4PT_User));
Eliminates all human players but excludes script players.
GetPlayerByName
GetPlayerName
GetPlayerCount
GetPlayerType
Sven2
2007-12