policeUnitDispatchRequest
When a player is wanted, their game sends police after them: cars, bikes, helicopters and their crews. Asks your gamemode before such a unit appears for everyone.
Renamed in 0.28 from policeDispatchRequest; see renamed names.
Signature
Section titled “Signature”server.on("policeUnitDispatchRequest", ({ player, unit, wantedLevel }) => boolean | void | Promise<boolean | void>)Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
player |
PlayerSnapshot |
The wanted player whose game sends the unit. |
unit |
DispatchUnitProposal |
The vehicle or ped and its crew. |
wantedLevel |
number |
The player’s wanted level, 1-6. |
Returns
Section titled “Returns”false keeps the unit and its crew away; nobody sees them. true, or nothing, lets them come. The first false
stops the handlers after it. See how decisions work.
Example
Section titled “Example”Police up to three stars, and never a police helicopter.
import { server } from "nativemp";
server.on("policeUnitDispatchRequest", ({ wantedLevel, unit }) => wantedLevel <= 3 && unit.model !== 497);Related
Section titled “Related”playerWantedLevelChangeRequest: decide before a wanted level changespoliceChaseTargetSwitchRequest: decide whether a unit switches to another player- Wanted and emergency guide