Chuyển tới nội dung chính

NPC_UseVehicleSiren

cảnh báo

This function was added in omp v1.5.8.3079 and will not work in earlier versions!

Description

Makes an NPC use or stop using a vehicle siren.

NameDescription
npcidThe ID of the NPC
usetrue to use siren, false to stop (default: true)

Returns

Returns true if the operation was successful, false otherwise.

Examples

public OnPlayerCommandText(playerid, cmdtext[])
{
if (!strcmp(cmdtext, "/npcusesiren ", true, 13))
{
new npcid = PlayerNPC[playerid];
if (npcid == INVALID_NPC_ID)
return SendClientMessage(playerid, 0xFF0000FF, "You are not debugging a NPC.");

if (!NPC_IsValid(npcid))
return SendClientMessage(playerid, 0xFF0000FF, "Invalid NPC.");

new veh = NPC_GetVehicle(npcid);
if (veh == INVALID_VEHICLE_ID)
return SendClientMessage(playerid, 0xFFFF00FF, "NPC %d is not in any vehicle.", npcid);

new bool:use = strval(cmdtext[13]) ? true : false;

new bool:success = NPC_UseVehicleSiren(npcid, use);

SendClientMessage(playerid, 0x00FF00FF, "NPC %d vehicle siren %s: %s", npcid, use ? "enabled" : "disabled", success ? "Success" : "Failed");
return 1;
}
return 0;
}

Notes

  • Only works when the NPC is in a vehicle as driver
  • The vehicle must support sirens (emergency vehicles)
  • Siren state persists until changed or NPC exits vehicle

No specific callbacks are triggered by this function.