diff --git a/integration/client/client.ts b/integration/client/client.ts index 176d730..1fbe57b 100644 --- a/integration/client/client.ts +++ b/integration/client/client.ts @@ -6,7 +6,7 @@ import { getIcon } from "~/utils/getIcon"; let firstSpawn = true; -onNet("playerSpawned", () => { +onNet(Events.CFXPlayerDropped, () => { if (firstSpawn) { emitPlayerData(); firstSpawn = false; diff --git a/integration/server/server.ts b/integration/server/server.ts index 6e927ee..4541ed4 100644 --- a/integration/server/server.ts +++ b/integration/server/server.ts @@ -12,7 +12,7 @@ const io = new Server(server, { const playerData = new Map(); -onNet(Events.ResourceStarted, (name: string) => { +onNet(Events.CFXResourceStarted, (name: string) => { const playerCount = GetNumPlayerIndices(); if (name !== GetCurrentResourceName()) return; @@ -24,6 +24,18 @@ onNet(Events.ResourceStarted, (name: string) => { }); }); +onNet(Events.CFXPlayerDropped, () => { + // @ts-expect-error - this is supported according to the docs. + const playerName = GetPlayerName(source); + + playerData.delete(playerName); + + io.sockets.emit("map-data", { + type: LegacyMapEvents.RemovePlayer, + payload: playerName, + }); +}); + onNet(Events.PlayerSpawned, (data: any) => { const identifiers = getPlayerIds(source); data.identifiers = identifiers; diff --git a/src/types/events.ts b/src/types/events.ts index 7e1855e..73adfa7 100644 --- a/src/types/events.ts +++ b/src/types/events.ts @@ -1,6 +1,9 @@ export enum Events { + CFXResourceStarted = "onResourceStart", + CFXPlayerDropped = "playerDropped", + CFXPlayerSpawned = "playerSpawned", + PlayerSpawned = "sna-live-map-player-spawned", - ResourceStarted = "onResourceStart", AddPlayerData = "sna-live-map-add-player-data", UpdatePlayerData = "sna-live-map-update-player-data", RemovePlayer = "sna-live-map-remove-player",