Skip to content

policeChaseTargetSwitchRequest

When several players are wanted, a police unit chasing one of them may come closer to another. Asks your gamemode whether it may switch to the nearer player.

Renamed in 0.28 from chaseTargetRequest; see renamed names.

server.on("policeChaseTargetSwitchRequest", ({ policeUnitNetworkId, currentTargetPlayer, proposedTargetPlayer }) =>
boolean | void | Promise<boolean | void>)
Name Type Description
policeUnitNetworkId number The police unit’s network ID.
currentTargetPlayer PlayerSnapshot The player it chases now.
proposedTargetPlayer PlayerSnapshot The nearer wanted player.

false keeps the unit on its current player; it may ask again later. true, or nothing, lets it switch. The first false stops the handlers after it. See how decisions work.

Switch only to a player with at least the same wanted level.

gamemodes/my-mode.ts
import { server } from "nativemp";
server.on("policeChaseTargetSwitchRequest", ({ currentTargetPlayer, proposedTargetPlayer }) =>
(proposedTargetPlayer.wantedLevel ?? 0) >= (currentTargetPlayer.wantedLevel ?? 0));