NPC_GetVehicleTrainSpeed
cảnh báo
Đã thêm hàm trong phiên bản omp v1.5.8.3079. Mục này không hoạt động trên các phiên bản cũ hơn!
Description
Gets the train speed for an NPC driving a train.
| Name | Description |
|---|---|
| npcid | The ID of the NPC |
Returns
Returns the train speed as a float, or 0.0 if not in a train.
Examples
public OnPlayerCommandText(playerid, cmdtext[])
{
if (!strcmp(cmdtext, "/checkvehicletrainspeed", 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.");
if (NPC_GetVehicle(npcid) == INVALID_VEHICLE_ID)
return SendClientMessage(playerid, 0xFFFF00FF, "NPC %d is not in any vehicle.", npcid);
new Float:speed = NPC_GetVehicleTrainSpeed(npcid);
SendClientMessage(playerid, 0x00FF00FF, "NPC %d vehicle train speed: %.2f", npcid, speed);
return 1;
}
return 0;
}
Notes
- Only works when the NPC is driving a train vehicle
- Returns 0.0 if the NPC is not in a train or not the driver
Related Functions
- NPC_SetVehicleTrainSpeed: Set train speed
- NPC_GetVehicleID: Get NPC's vehicle
- NPC_PutInVehicle: Put NPC in vehicle
Related Callbacks
No specific callbacks are triggered by this function.