Skip to content

players.listOnline

Returns a snapshot of every connected player, including players who are still held before their first spawn.

Renamed in 0.28 from players.online; see renamed names.

players.listOnline(): readonly PlayerSnapshot[]

None.

An array of PlayerSnapshot. It is a copy: it does not change as players come and go.

Greet whoever is already online when the gamemode starts, for instance after a reload.

gamemodes/my-mode.ts
import { chat, players } from "nativemp";
for (const player of players.listOnline()) {
chat.sendServerMessage(`The server's gamemode was just restarted. Welcome back, ${player.name}.`, player);
}