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.
Signature
Section titled “Signature”server.on("playerArrested", ({ player, position, copNetworkId, isHandledByGamemode }) => void)Parameters
Section titled “Parameters”| 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. |
Example
Section titled “Example”Send a busted player to jail, and fine them.
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.`);});Related
Section titled “Related”players.setSurvivalPolicy: who handles an arrestplayerStateChanged: a busted player’s state isbustedplayerWantedLevelChanged: the wanted level