Versions Compared
Key
- This line was added.
- This line was removed.
- Formatting was changed.
Excerpt |
---|
An array of Player objects describing each human/AI player slot on the current map regardless of whether those slots have been assigned players for the current game. |
Overview
By inspecting the player data stored in this array, you can determine some useful information about your opponents/allies.The data is based on either the settings in a campaign file, or the game settings from a skirmish or multiplayer game: For example, what colour or difficulty was set on the game set-up screen?
There can be up to 10 players "normal" – human or AI bot (eg. Nexus, Semperfi, NullBot, etc) – players in a game and, and optionally, a scavenger player. The scavenger player Scavenger player.
If a player slot is "Closed" (no player assigned) on the game set-up screen, they will still be included in the playerData array – so you cannot assume that each of the players listed in the array are active players.
Properties
The Scavenger player does not appear in the playerData array and does not have a player object and is thus not referenced in the playerData array.
The index of each element is the player's ID within the game (the value of me for that player). Note that this is not necessarily the same as the player's position on the map - for example, some starting positions might not have been assigned a player.
Properties
Each (numerically referenced) element in the array contains a Player object.
See scavengers and scavengerPlayer globals for more information on working with Scavengers.
Property | Type | Notes | Game Version |
---|---|---|---|
<N> | Player object | The numeric element indexes in the array represent the player IDs. So, playerData[me] gives the player object for the player associated with your script, playerData[0] is the player object for player #0, etc. Note: Not the same as a map position! Example: Player 2 might be in map position 0. The "position" property of a player object states which map position a player is in. | 3.1 |
.length | Number | The number of "normal" players in the game (same value as maxPlayers). Players are zero-indexed, so if a game as 4 players the <n> elements would be numbered 0..3, etc. | 3.1 |
The playerData array is a normal array and thus inherits all standard methods and properties of the Javascript Array class.
Examples
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
playerData.forEach(function(data, player) { // player = player id // data = Player object containing info about that player }); |
Div | ||
---|---|---|
| ||
AvailabilityAvailable since:
|
Div | ||
---|---|---|
| ||
See alsoRelated API features:
You might also like:
|