This AI is still in early stages of development.
Players[]
- Aubergine
Â
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:
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 |
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.
// 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 });
Contents
Jump to:
See also
Related articles:
- me – the ID of the player associated with your script
- playerData[] – the native JS API player data array (not altered by Players API)
- Player object – the native JS API player object definition (not altered by Players API)
- selectedPlayer – the player the local host human is currently playing as (they can change it via the Debug Menu)
- scavengerPlayer – the ID of the Scavengers faction
Players API
Topics:
- isPlayerAlive() — A global function that performs a basic, un-cached check to determine if a player is alive.
- eventTeamRevived() — A global event triggered when a team is revived (one or more of it's players resurrected).
- eventPlayerDefeated() — A global event triggered when a player is defeated.
- eventPlayerRevived() — A global event triggered when a player is revived (brought back to life).
- Modding Players API — The Players API supports modding...
- isSpectator() — A global function that performs a basic, un-cached check to determine if a player is a spectator based on presence of a Satellite Uplink at the start of the game.
- Players[] — Main interface to Players API and an array of all players in the game, including Scavengers.
- Players.alliesAndMe[] — Returns an array of players objects for living allied players, including me.
- Players.alive[] — Returns an array of players objects for living players.
- Players.allies[] — Returns an array of players objects for living allied players.
- Players.refresh() — Rebuilds all Players Objects, use with care!
- Players.dead[] — Returns an array of players objects for dead players.
- Players.scavenger — Returns the players object associated with the Scavenger faction, even if Scavengers are disabled.
- Players.me — Returns the player object associated with your script.
- Players.enemies[] — Returns an array of players objects for living enemy players.
- Players.mod() — Extend the Players API and Players Objects with your own features...
- Players Objects — The objects returned by the Players API are enhanced versions of Player objects...
- eventTeamDefeated() — A global event triggered when a team is defeated (all it's players defeated).
Â