跳到主要内容

NPC_GetVehicleTrainSpeed

注意

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

描述

获取 NPC 驾驶的火车的速度。

参数说明
npcidNPC 的 ID

返回值

返回火车速度(浮点数),若不在火车中则返回 0.0。

示例

public OnPlayerCommandText(playerid, cmdtext[])
{
if (!strcmp(cmdtext, "/checkvehicletrainspeed", 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 (NPC_GetVehicle(npcid) == INVALID_VEHICLE_ID)
return SendClientMessage(playerid, 0xFFFF00FF, "NPC %d 没在任何车辆中。", npcid);

new Float:speed = NPC_GetVehicleTrainSpeed(npcid);

SendClientMessage(playerid, 0x00FF00FF, "NPC %d 驾驶的火车的速度: %.2f", npcid, speed);
return 1;
}
return 0;
}

注意事项

  • 仅在 NPC 驾驶火车车辆时有效
  • 若 NPC 不在火车中或不是驾驶员则返回 0.0

相关函数

相关回调

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