跳到主要内容

NPC_GetEnteringVehicleSeat

注意

这个函数是在omp v1.5.8.3079中添加的,在以前的版本中不起作用!

描述

获取 NPC 在车辆中正在进入的座位。

参数说明
npcidNPC 的 ID

返回值

返回 NPC 正在进入的座位号,若未进入则返回-1。

示例

public OnPlayerCommandText(playerid, cmdtext[])
{
if (!strcmp(cmdtext, "/checkenterveh", true))
{
new npcid = PlayerNPC[playerid];
if (npcid == INVALID_NPC_ID)
return SendClientMessage(playerid, 0xFF0000FF, "你没有在调试NPC。");

if (!NPC_IsValid(npcid))
return SendClientMessage(playerid, 0xFF0000FF, "无效的NPC。");

// 如果尚未运行,则开始监视
if (PlayerEnterVehicleMonitor[playerid] == INVALID_TIMER_ID)
{
PlayerEnterVehicleMonitor[playerid] = SetTimerEx("CheckNPCEnteringVehicle", 200, true, "i", playerid);
PlayerWasEnteringVehicle[playerid] = false;
SendClientMessage(playerid, 0x00FF00FF, "开始监控 NPC %d 的车辆进入状态。", npcid);
}
else
{
SendClientMessage(playerid, 0xFFFF00FF, "已在监控 NPC %d 的车辆进入状态。", npcid);
}
return 1;
}
return 0;
}

forward CheckNPCEnteringVehicle(playerid);
public CheckNPCEnteringVehicle(playerid)
{
if (!IsPlayerConnected(playerid))
{
StopPlayerEnterVehicleMonitor(playerid);
return 0;
}

new npcid = PlayerNPC[playerid];
if (npcid == INVALID_NPC_ID || !NPC_IsValid(npcid))
{
StopPlayerEnterVehicleMonitor(playerid);
return 0;
}

new bool:isEntering = NPC_IsEnteringVehicle(npcid);

if (isEntering)
{
new vehicleid = NPC_GetEnteringVehicle(npcid);
new seatid = NPC_GetEnteringVehicleSeat(npcid);

if (vehicleid != INVALID_VEHICLE_ID && vehicleid != 0)
{
SendClientMessage(playerid, 0xFFFF00FF, "NPC %d 正在进入车辆 %d(座位 %d)", npcid, vehicleid, seatid);
}
}

return 1;
}

座位 ID

ID座位
0驾驶员
1副驾驶乘客
2后左乘客
3后右乘客
4+乘客座位(大巴等)

注意事项

  • 若 NPC 未进入任何车辆,则返回-1
  • 此信息仅在 NPC 处于进入过程中时有效

相关函数

相关回调

此函数不会触发任何特定的回调。