Versions Compared
Key
- This line was added.
- This line was removed.
- Formatting was changed.
Excerpt |
---|
Main interface to Players API and an array of all players in the game, including Scavengers. |
Properties
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:
ReferenceError will be thrown.
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 doesndeveloper didn't have a scavenger faction 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 one game tick100ms. | 1.0 |
allies | Array of Players Objects | An array of objects for all living allies, excluding me, spectators and vacant slots. Cached for one game tick1 second. | 1.0 |
alliesAndMe | Array of Players Objects | Same as .allies, but also includes me. Cached for one game tick5 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 one game tick100ms. | 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 one game tick10 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 |
Examples
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.
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
// 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 }); |
Div | ||||||
---|---|---|---|---|---|---|
| ||||||
Availability
Requires:
|
Div | ||||
---|---|---|---|---|
| ||||
ContentsJump to:
|
Div | ||
---|---|---|
| ||
See alsoRelated articles:
|
Div | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
Players APITopics:
|