Skip to main content

Overview

The Team class represents one of the two teams in a match, managing its roster of players, score tracking, timeout state, and round-by-round history.

Team Class

export class Team {
  // Identity
  public teamName: string;
  public teamTricode: string;
  public teamUrl: string = "";
  
  // Game State
  public ingameTeamId: number = 0;  // 0 or 1
  public isAttacking: boolean = false;
  public roundsWon: number = 0;
  
  // Players
  private players: Player[] = [];
  private playerCount: number = 0;
  private hasDuplicateAgents: boolean = false;
  
  // Economy
  private spentThisRound: number = 0;
  
  // Round History
  private roundRecord: RecordEntry[] = [];
  
  // Configuration
  private removeTricode: boolean = false;
  private hasHandledTeam: boolean = false;
}

Properties

Identity

teamName
string
Full team name (e.g., “Sentinels”).
teamTricode
string
3-letter team code (e.g., “SEN”).
teamUrl
string
default:""
URL to team logo image.

Game State

ingameTeamId
number
In-game team identifier.
isAttacking
boolean
Whether the team is currently on the attacking side.
roundsWon
number
default:"0"
Total rounds won in the match.

Players

players
Player[]
Array of up to 5 players on the team.
playerCount
number
Number of players currently in the roster (0-5).
hasDuplicateAgents
boolean
default:"false"
Whether any two players have selected the same agent (affects assist tracking).

Economy

spentThisRound
number
Total credits spent by all team members in the current round.

Round History

roundRecord
RecordEntry[]
Array of round results and win conditions.Pre-initialized with 26 “upcoming” entries.

Constructor

constructor(team: AuthTeam, removeTricode: boolean)
team
AuthTeam
required
Team configuration from authentication data:
{
  name: string;        // Team name
  tricode: string;     // 3-letter code
  url: string;         // Logo URL
  attackStart: boolean; // Starting side
}
removeTricode
boolean
required
Whether to strip the tricode prefix from player names (from playercams settings).

Core Methods

receiveTeamSpecificData

public receiveTeamSpecificData(data: IAuthedData | IAuthedAuxData | IFormattedAuxiliary): void
Routes incoming event data to the appropriate handler and updates team/player state.
data
IAuthedData | IAuthedAuxData | IFormattedAuxiliary
required

receiveAuxScoreboardTeamData

public receiveAuxScoreboardTeamData(scoreboards: IFormattedAuxScoreboardTeam[]): void
Batch processes scoreboard data for all team members from auxiliary client.

switchSides

public switchSides(): void
Toggles the isAttacking flag. Called at half (round 13) and every 2 rounds in overtime.

resetRoundSpecificValues

public resetRoundSpecificValues(isSideSwitch: boolean): void
Resets round-specific data for all players at the start of each round.
isSideSwitch
boolean
required
If true, resets player money to 800 (pistol round economy).

addRoundReason

public addRoundReason(reason: RecordType, roundNumber: number): void
Records the outcome of a round in the team’s history.
reason
RecordType
required
roundNumber
number
required
The round number (1-indexed).

Player Queries

public hasTeamMemberByName(playerName: string): boolean
public hasTeamMemberBySearchName(playerSearchName: string): boolean
public hasTeamMemberById(playerId: string): boolean
public getPlayerCount(): number
public getFirstPlayerId(): string
public alivePlayers(): number
public getMoneyFor(playerId: string): number

setObservedPlayer

public setObservedPlayer(observedName: string): void
Updates all players’ isObserved flag based on the camera target.

findDuplicateAgents

public findDuplicateAgents(): void
Checks if any two players have the same agent selected. Sets hasDuplicateAgents flag, which affects assist attribution logic.

getSpentThisRound

public getSpentThisRound(): number
Calculates total money spent by all players in the current round.

setAuxDisconnected

public setAuxDisconnected(playerId: string): void
Marks a specific player’s auxiliary data as disconnected.

Supporting Types

RecordEntry

export interface RecordEntry {
  type: RecordType;
  wasAttack: boolean;
  round: number;
}
type
RecordType
The outcome type (see addRoundReason above).
wasAttack
boolean
Whether the team was attacking when this round was played.
round
number
The round number.

RecordType

type RecordType = "detonated" | "defused" | "kills" | "timeout" | "lost" | "upcoming";

Example Usage

// Team is created during match initialization
const teamConfig: AuthTeam = {
  name: "Sentinels",
  tricode: "SEN",
  url: "https://example.com/sentinels-logo.png",
  attackStart: true
};

const team = new Team(teamConfig, false);

// Process roster data
team.receiveTeamSpecificData({
  obsName: "Observer1",
  groupCode: "ABC123",
  type: DataTypes.ROSTER,
  timestamp: Date.now(),
  data: {
    name: "TenZ",
    tagline: "SEN",
    playerId: "player-uuid-1",
    startTeam: 0,
    agentInternal: "Jett_PC_C",
    position: 0,
    locked: true,
    rank: 28
  }
});

// Update scoreboard
team.receiveTeamSpecificData({
  obsName: "Observer1",
  groupCode: "ABC123",
  type: DataTypes.SCOREBOARD,
  timestamp: Date.now(),
  data: {
    name: "TenZ",
    tagline: "SEN",
    playerId: "player-uuid-1",
    startTeam: 0,
    agentInternal: "Jett_PC_C",
    isAlive: true,
    initialArmor: 2,
    scoreboardWeaponInternal: "operator",
    currUltPoints: 7,
    maxUltPoints: 7,
    hasSpike: false,
    money: 2700,
    kills: 15,
    deaths: 10,
    assists: 3
  }
});

// Record round outcome
team.addRoundReason("kills", 1);

// Switch sides at half
team.switchSides();

console.log(team.isAttacking); // false (was true)
console.log(team.getPlayerCount()); // 1
console.log(team.alivePlayers()); // 1
console.log(team.getSpentThisRound()); // Credits spent by all players

Roster Management

Build docs developers (and LLMs) love