# GetPlayerID

Player
5.1 OC
int
int player Player of which to retrieve the ID.
Returns the player-ID of a joined player. Player-IDs are being counted upwards starting at 1. Other than player numbers, they won't be used again after a player has been eliminated. Each newly joined player has a unique ID.
In network games, player IDs are being assigned in the lobby phase. Because lobby players might be removed before the game start (either manually or by disconnecting clients), you cannot assume that all player-IDs from 1 to GetPlayerCount() are set.
static player_names, player_scores;

protected func Initialize() { if(!player_names) player_names = CreateArray(); if(!player_scores) player_scores = CreateArray(); }

protected func RemovePlayer(int player) { var player_id = GetPlayerID(player); player_names[player_id] = GetPlayerName(player); player_scores[player_id] = GetScore(player); }

protected func OnGameOver() { Log("Scores of eliminated players:"); for (var i = 0; i < GetLength(player_names); ++i) if (player_names[i]) Log(Format("%s - %d", player_names[i], player_scores[i])); }
Saves the scores and names of all players in a list when they are eliminated. Once the round is over, this list is displayed in the log. Using player-IDs instead of player numbers as list indices guarantuees that rejoining players will not overwrite scores of previous players.
GetPlayerTeam
Sven2
2006-03