Skip to content

playerConnectRequest

Asks your gamemode whether a player may join, before they are let in. The server has already checked the nickname, the number of players, the game version and address bans.

Renamed in 0.28 from connectRequest; see renamed names.

server.on("playerConnectRequest", ({ nickname, address, clientBuild }) => ConnectDecision | false | Promise<ConnectDecision | false>)
Name Type Description
nickname string The nickname the player chose.
address string The player’s network address; what an address ban matches.
clientBuild string The client build the player’s launcher reports. Unverified.

{ allow: true } lets the player in. { allow: false, reason } refuses them with a reason they see in their launcher (up to 128 bytes); false refuses them with “Refused by the server.” Returning nothing lets them in. The first refusal stops the handlers after it. See how decisions work.

A small nickname allowlist. A production mode can replace the lookup with its own account policy.

gamemodes/whitelist.ts
import { server } from "nativemp";
const allowedNames = new Set(["Alice", "Bob"]);
server.on("playerConnectRequest", ({ nickname }) => {
const allowed = allowedNames.has(nickname);
return allowed ? { allow: true } : { allow: false, reason: "This server is whitelisted. Apply on our Discord." };
});