Skip to content

playerSnapshotUpdated

Tells your gamemode when the server accepts new state for a player: position, health, weapon and the rest. Updates are combined to at most ten per second per player; lifecycle and vehicle changes come at once.

A spectator or freecam player sends no state of their own, so they get none, with two opt-in exceptions: a view started with listenAtView keeps updating their listenPosition (at the same rate), and players.setListenPosition updates it once. Their position stays where they started watching.

Renamed in 0.28 from playerStateUpdate; see renamed names.

server.on("playerSnapshotUpdated", ({ player }) => void)
Name Type Description
player PlayerSnapshot The updated snapshot.

Keep players out of a square of the map.

gamemodes/my-mode.ts
import { players, server } from "nativemp";
server.on("playerSnapshotUpdated", async ({ player }) => {
const [x, y] = player.position ?? [0, 0];
if (x > 1000 && x < 1200 && y > 1000 && y < 1200) {
await players.setPosition(player, [1100, 950, 20]);
}
});