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.
Signature
Section titled “Signature”players.listOnline(): readonly PlayerSnapshot[]Parameters
Section titled “Parameters”None.
Returns
Section titled “Returns”An array of PlayerSnapshot. It is a copy: it does not change as players come and go.
Example
Section titled “Example”Greet whoever is already online when the gamemode starts, for instance after a reload.
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);}Related
Section titled “Related”players.getById: one player by IDplayerConnected: a player has joined