vehicleSirenChanged
Tells your gamemode that a vehicle’s siren changed: switched by the driver, by an NPC, or by your gamemode. It is also
sent when a vehicle with a siren appears and when it goes. vehicles.getSirenState
already returns the new state.
Signature
Section titled “Signature”server.on("vehicleSirenChanged", ({ vehicleId, fromActive, toActive, hasAddedSiren, reason, observedAtSessionMs }) => void)Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
vehicleId |
number |
The vehicle. |
fromActive |
boolean or null |
The siren before; null when the vehicle just appeared. |
toActive |
boolean or null |
The siren now; null when the vehicle is gone. |
hasAddedSiren |
boolean |
true when your gamemode gave the vehicle its siren with vehicles.setHasSiren. |
reason |
"created" | "native" | "request" | "script" | "removed" |
The vehicle appeared, an NPC switched it, someone in the vehicle switched it, your gamemode switched it, or the vehicle is gone. |
observedAtSessionMs |
number |
When, on the shared session clock. |
Example
Section titled “Example”import { server, vehicles } from "nativemp";
server.on("vehicleSirenChanged", ({ vehicleId, reason }) => { const current = vehicles.getSirenState(vehicleId); server.log(`Vehicle ${vehicleId}: ${current?.active ?? "gone"} (${reason})`);});Related
Section titled “Related”vehicleSirenChangeRequest: decide whether the driver may switch itvehicles.setSiren: switch it from your gamemodevehicles.getSirenState: read it