Skip to content

players.kick

Disconnects a player. Their launcher shows the disconnected dialog with Kicked: and your reason.

players.kick(player: PlayerTarget, reason?: string): Promise<ActionResult>
Name Type Description
player PlayerTarget The player, or their ID.
reason string Optional. Up to 128 bytes, without control characters. Defaults to Kicked by the server.

A promise of an ActionResult: applied once the server has disconnected the player.

A /kick for admins.

gamemodes/admin.ts
import { chat, commands, players } from "nativemp";
const admins = new Set(["Arjan"]);
commands.register("kick", async (player, args) => {
const [id, ...reason] = args.trim().split(" ");
const result = await players.kick(Number(id), reason.join(" ") || undefined);
if (result.status === "rejected") chat.sendServerMessage(`Kick failed: ${result.code}`, player);
}, { authorize: (player) => admins.has(player.name), denyMessage: "Admins only." });

A captured Player keeps this effect bound to its connection across awaits; see Async handlers.