跳到主要內容

NPC_EnterVehicle

注意

此函式於 omp v1.5.8.3079 版本中新增,在更早的版本中無法使用!

Description​

Makes an NPC enter a vehicle by walking to it and getting in.

NameDescription
npcidThe ID of the NPC
vehicleidThe ID of the vehicle to enter
seatidThe seat to enter
moveTypeThe movement type to use when approaching

Returns​

Returns true if the operation was successful, false otherwise.

Examples​

public OnPlayerCommandText(playerid, cmdtext[])
{
if (!strcmp(cmdtext, "/npcenterbike ", true, 14))
{
new seatid = strval(cmdtext[15]);
if (cmdtext[15] == '\0')
return SendClientMessage(playerid, 0xFF0000FF, "Usage: /npcenterbike [seatid]");

new npcid = PlayerNPC[playerid];
if (npcid == INVALID_NPC_ID)
return SendClientMessage(playerid, 0xFF0000FF, "You are not debugging a NPC.");

new vehicleid = PlayerVehicles[playerid][0];
if (vehicleid == INVALID_VEHICLE_ID)
return SendClientMessage(playerid, 0xFF0000FF, "Your motorcycle is not available.");

if (NPC_EnterVehicle(npcid, vehicleid, seatid, NPC_MOVE_TYPE_JOG))
SendClientMessage(playerid, 0x00FF00FF, "NPC %d is entering motorcycle (seat %d).", npcid, seatid);
else
SendClientMessage(playerid, 0xFF0000FF, "NPC %d failed to enter motorcycle (seat %d).", npcid, seatid);

return 1;
}
return 0;
}

Seat IDs​

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

Notes​

  • The NPC will try to reach the vehicle door, using the specified movement type, before entering
  • If the seat is occupied, the NPC may not be able to enter

No specific callbacks are triggered by this function.