Proximity chat for modders
Proximity chat lets players in a Cosmic Helm voice bay hear the people near them in a game, louder the closer they are. Cosmic Helm does the voice and the hearing. The game only needs a Cosmic Helm-compatible mod or plugin on its server that sends where each player is. Cosmic Helm doesn’t make these mods: server owners and modders build and share their own. This page is everything a mod needs.
How it fits together
- A crew owner turns Proximity chat on for a voice bay in that bay’s settings, picks the game and presses Generate key. Each bay with Proximity chat has its own key (it starts with
chgs_), so one crew can run several games at once. The key is shown once; resetting it stops the old one at once. - The server owner puts the key in your mod’s config, with the address
https://cosmichelm.com(let people change it). - Your mod connects: it calls
GET /api/game/hellowith the key, then sends player positions several times a second while anyone is online. - Players link their character: they type your link command in the game, your mod asks Cosmic Helm for a 6-character code and shows it, and they enter it in Cosmic Helm under Settings → Linked games. From then on their voice in the bay follows their character.
The calls
Every call sends the bay’s key: Authorization: Bearer chgs_…. JSON in, JSON out.
| Call | Body or query | Answer |
|---|---|---|
GET /api/game/hello | none | { server, game, game_name, unit, bay, range, lobby, max_players, per_second }: which bay the key belongs to and its limits. Log “Connected” when it answers 200. |
POST /api/game/positions | { players: [{ playerUid, x, y, z, dimension }] } | { ok, players, listeners } |
POST /api/game/link | { playerUid, playerName } | { code, expires_in }: a 6-character code (10 minutes) to show the player |
POST /api/game/unlink | { playerUid } | { ok } |
GET /api/game/status?playerUid= | none | { linked, account, bay, in_voice, hearing, range, lobby, server }, for a status command |
Positions
playerUid: the game’s own stable id for the player (up to 128 characters), never a display name, which can change.x,y,z: numbers in the game’s own units (blocks, metres). The crew owner sets the hearing range in the same units.dimension: optional text (up to 64 characters) for places players can’t hear across, like another world or an instance. Leave it out if the game has one world.- Send everyone online in each batch: anyone left out has left the world. A player whose position hasn’t come for 10 seconds counts as outside the world.
Limits
- At most 5 batches a second (one every 200 ms).
- At most 150 players in a batch.
Errors
Errors are { error: "plain words" } with a status:
- 401: an unknown or removed key (it was reset, or Proximity chat was turned off for the bay). Stop and log it once; don’t retry fast.
- 429: more than 5 a second. Slow down.
- 413: more than 150 players in one batch.
- 400: a missing or wrong field.
- 404: Proximity chat isn’t available.
On network errors, wait longer after each failure (1 second, then longer, up to 30 seconds) and log once. Never make the game wait for Cosmic Helm.
Privacy and safety
Send only player ids, names (for the link code) and positions. Never chat, IP addresses or anything else. Keep the key out of logs.
An example
A server-side mod for Vintage Story was written as an example. This is its loop, in short (C#): about 4 times a second it sends everyone online.
// every 250 ms, on the server
var players = sapi.World.AllOnlinePlayers.OfType<IServerPlayer>().Select(p => new {
playerUid = p.PlayerUID,
x = p.Entity.Pos.X, y = p.Entity.Pos.Y, z = p.Entity.Pos.Z,
dimension = p.Entity.Pos.Dimension
});
var req = new HttpRequestMessage(HttpMethod.Post, endpoint + "/api/game/positions");
req.Headers.Authorization = new AuthenticationHeaderValue("Bearer", key);
req.Content = JsonContent.Create(new { players });
var res = await http.SendAsync(req); // 401: stop; 429: slow down; network error: back off
Its link command calls POST /api/game/link and shows the code in the game’s chat. The config holds the key and the address:
{ "Key": "chgs_…", "Endpoint": "https://cosmichelm.com" }
What players see
Once your mod is connected, the bay’s settings show Connected, and people in the bay who have linked their character hear each other by distance. Everyone else in the bay hears as in a normal voice bay.