Pular para o conteúdo principal

NPC_PutInVehicle

atenção

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

Description

Puts an NPC into a vehicle at a specific seat.

NameDescription
npcidThe ID of the NPC
vehicleidThe ID of the vehicle
seatidThe seat ID to put the NPC in

Returns

Returns true if the NPC was put in the vehicle successfully, false otherwise.

Examples

public OnPlayerCommandText(playerid, cmdtext[])
{
if (!strcmp(cmdtext, "/npcputinvehicle", true))
{
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 vehicleid = GetPlayerVehicleID(playerid);
if (vehicleid == 0)
return SendClientMessage(playerid, 0xFF0000FF, "You are not in a vehicle.");

new bool:success = NPC_PutInVehicle(npcid, vehicleid, 1);

SendClientMessage(playerid, 0x00FF00FF, "NPC %d put in vehicle %d (seat 1): %s", npcid, vehicleid, success ? "Success" : "Failed");
return 1;
}
return 0;
}

Seat IDs

IDSeat
0Driver
1Front passenger
2Back-left passenger
3Back-right passenger
4+Passenger seats (coach etc.)

Notes

  • NPC will instantly appear in the vehicle without enter animation
  • Use NPC_GetVehicleID to check which vehicle an NPC is in
  • Seat 0 is always the driver seat
  • Maximum seat ID depends on the vehicle model

No specific callbacks are triggered by this function.