Pular para o conteúdo principal

NPC_EnterVehicle

atenção

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

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[14]);
if (cmdtext[14] == '\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.