players.kick
Disconnects a player. Their launcher shows the disconnected dialog with Kicked: and your reason.
Signature
Section titled “Signature”players.kick(player: PlayerTarget, reason?: string): Promise<ActionResult>Parameters
Section titled “Parameters”| 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. |
Returns
Section titled “Returns”A promise of an ActionResult: applied once the server has disconnected the player.
Example
Section titled “Example”A /kick for admins.
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." });Related
Section titled “Related”players.banAddress: keep them outplayerDisconnected: fires for the kicked player
A captured Player keeps this effect bound to its connection across awaits; see Async handlers.