Skip to content

playerArrested

Tells your gamemode when a cop arrests a player.

What happens next depends on the player’s survival policy. By default the game shows the Busted screen and the player respawns. With arrestHandling: "gamemode" the player stays where they were and you decide.

server.on("playerArrested", ({ player, position, copNetworkId, isHandledByGamemode }) => void)
Name Type Description
player PlayerSnapshot The player.
position Vector3 Where they were arrested.
copNetworkId number | null The network ID of the cop who arrested them, or null when the server does not know that cop.
isHandledByGamemode boolean true: no Busted screen; the player is still there, alive and wanted, and what happens is up to you. false: the game busts them and they respawn.

Send a busted player to jail, and fine them.

gamemodes/my-mode.ts
import { chat, players, server } from "nativemp";
server.on("playerConnected", async ({ player }) => {
await players.setSurvivalPolicy(player, { arrestHandling: "gamemode" });
});
server.on("playerArrested", async ({ player, isHandledByGamemode }) => {
if (!isHandledByGamemode) return;
await players.setWantedLevel(player, 0);
await players.giveMoney(player, -500);
await players.setPosition(player, [264.6, 77.6, 1001.0], 0, 6);
chat.sendServerMessage(`${player.name} was taken to jail.`);
});