Skip to content

players.setWantedLevel

Sets a player’s wanted level, 0 to 6 stars. The player’s own game runs the police that come after them.

players.setWantedLevel(player: PlayerTarget, level: number): Promise<ActionResult>
Name Type Description
player PlayerTarget The player, or their ID.
level number Stars, 0 to 6. 0 clears it.

A promise of an ActionResult: applied once the server has set it (also when the player already had that level), or rejected with a code: vetoed when playerWantedLevelChangeRequest refused it. A newer call replaces one still waiting for that decision. applied means the server set it; the player’s game follows.

A /surrender that clears the stars.

gamemodes/my-mode.ts
import { chat, commands, players } from "nativemp";
commands.register("surrender", async (player) => {
const result = await players.setWantedLevel(player, 0);
if (result.status !== "applied") chat.sendServerMessage(result.status === "rejected" ? result.code : "timeout", player);
});

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