Main interface to Players API and an array of all players in the game, including Scavengers. |
Always use .forEach() method to iterate arrays retuned by the Players API (see Examples section).
Where applicable, caching is applied for a single game tick to minimise code execution. For more information on caching and "game ticks" see Cache API.
The .enemies, .allies, .living and .dead arrays use sequential indexes and not player ids. Use the .id property of the players object instead (see Examples section).
Property | Type | Notes | API Version |
---|---|---|---|
<playerID> | Players Object | Numeric player ID references return the object associated with the player. Examples:
Pay particular attention to scavengerPlayer which can have a value of If the specified player does not exist, a | 1.0 |
scavenger | Players Object | The players object associated with scavenger faction, even if scavenger faction is not present. You can check For example, scavengers might be enabled on the map, but if the map developer didn't add Scavengers to their map there won't be any scavengers! Scavengers don't have a start position so:
| 1.0 |
enemies | Array of Players Objects | An array of objects for all living enemies, including scavengers (if applicable), excluding spectators and vacant slots. Cached for 100ms. | 1.0 |
allies | Array of Players Objects | An array of objects for all living allies, excluding me, spectators and vacant slots. Cached for 1 second. | 1.0 |
alliesAndMe | Array of Players Objects | Same as .allies, but also includes me. Cached for 5 seconds. | |
alive | Array of Players Objects | An array of objects for all living players, including scavengers (if living), excluding spectators and vacant slots. Cached for 100ms. | 1.0 |
dead | Array of Players Objects | An array of objects for all defeated players, including scavengers (if defeated), excluding spectators and vacant slots. Cached for 10 seconds. | 1.0 |
me | Players Object | The players object associated with your script. You can check | 1.0 |
Number | Do not use or small furry animals will die painful deaths. | 1.0 |
When iterating over arrays of player objects, including the main Players[] array, always use Javascript's .forEach() method as it deals with gaps in the array which can be caused by scavengerPlayer.
// list of all players Players.forEach(function(player) { // player == players object associated with player // player.id == player id }); // pre-filtered list of living enemies Players.enemies.forEach(function(enemy) { // enemy == players object associated with the player // enemy.id == player id }); |
AvailabilityRequires:
|
ContentsJump to: |
See alsoRelated articles:
|
Players APITopics: |