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.
Signature
Section titled “Signature”server.on("policeChaseTargetSwitchRequest", ({ policeUnitNetworkId, currentTargetPlayer, proposedTargetPlayer }) => boolean | void | Promise<boolean | void>)Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
policeUnitNetworkId |
number |
The police unit’s network ID. |
currentTargetPlayer |
PlayerSnapshot |
The player it chases now. |
proposedTargetPlayer |
PlayerSnapshot |
The nearer wanted player. |
Returns
Section titled “Returns”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.
Example
Section titled “Example”Switch only to a player with at least the same wanted level.
import { server } from "nativemp";
server.on("policeChaseTargetSwitchRequest", ({ currentTargetPlayer, proposedTargetPlayer }) => (proposedTargetPlayer.wantedLevel ?? 0) >= (currentTargetPlayer.wantedLevel ?? 0));Related
Section titled “Related”policeUnitDispatchRequest: decide whether a police unit comesplayerWantedLevelChangeRequest: decide before a wanted level changes- Wanted and emergency guide