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. For example, what colour or difficulty was set on the game set-up screen?

There can be up to 10 "normal" – human or AI bot (eg. Nexus, Semperfi, NullBot, etc) – players in a game and, optionally, a 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

(warning) The Scavenger player does not appear in the playerData array and does not have a player object.
     See scavengers and scavengerPlayer globals for more information on working with Scavengers.

PropertyTypeNotesGame 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
.lengthNumber

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
themeRDark
languagejavascript
titleIterate through playerData array
linenumberstrue
playerData.forEach( function get(data, player) {
	// player = player id
    // data = Player object containing info about that player
});
Div
classbox
Availability
Status
colourGreen
title3.1 b1+

Available since:

  • Warzone 3.1 Beta 1
  • See Player object for details of subsequent updates.
Div
classbox
Contents

Jump to:

Table of Contents
maxLevel5

Div
classbox

See also

Related API features:

You might also like: