In order to subscribe to events for a given game, you’ll need to use the game’s respective module. This helps with bundle sizes so you only load the event code that you need, and helps organize our architecture. View our supported games and their events here.

Example

import * as Siege from "@overlayed/app/siege";
import { overlayed } from "@overlayed/app";

const overlay = overlayed({
	modules: [Siege.module()],
});

overlay.siege.on("player_joined", (event) => {
	// ...
});

// Call this when you're ready to receive game events
overlay.siege.readyForGameEvents();

Listening to any event

overlay.siege.onAny((event) => {
	// ...
});

// Call this when you're ready to receive game events
overlay.siege.readyForGameEvents();

Event Queuing

When your overlay initializes, any incoming game events are automatically queued and stored until you explicitly call readyForGameEvents() on the respective game module. This ensures you don’t miss any events that occur during your application’s startup phase.
// Events are queued until readyForGameEvents() is called
overlay.siege.on("player_joined", handlePlayerJoined);
overlay.siege.on("round_started", handleRoundStarted);

// When ready, flush all queued events and start receiving new ones immediately
overlay.siege.readyForGameEvents();
You must call readyForGameEvents() on each game module you want to receive events from. Events will remain queued until this method is called, with a max limit of 1000.

Typed and Validated

All events are validated with Arktype and fully typed. This means you can be confident in the data you receive, and will never run into an event with a missing property or incorrect type. We expose all of the types for each event on the module, for example:
import { PlayerJoinedEvent } from "@overlayed/app/siege";

type T = PlayerJoinedEvent;

Constants

We also expose helpful constants and other game data on the module, for example:
import { SIEGE_DAMAGE_TYPES, SIEGE_TEAMS, SIEGE_SIDES } from "@overlayed/app/siege";

SIEGE_DAMAGE_TYPES; // ["bullet", "melee", "explosive", "falling", "regeneration", "unknown", "debris", "projectile", "downed", "gas", "thermal_explosion", "melee_gadget", "barbed_wire", "electric", "reinforcement", "frag", "paralyzed", "emp", "break", "cleanup", "interrogation", "melee-finisher", "toxic", "toxic-explosion", "pneumatic", "body-contact", "contact-explosion", "flash", "parasite-spike", "laser", "concussion", "blowtorch", "taser-shield", "reverse-friendly-fire", "self-destroyed", "area-control", "fire", "breach-kick", "break-wall", "blade-mine", "invalid"]
SIEGE_TEAMS; // [0, 1],
SIEGE_SIDES; // ["attacker", "defender", "both", "invalid"]