Skip to main content

NPC_SetVehicleTrainSpeed

warning

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

Description​

Sets the speed of an NPC's train vehicle.

NameDescription
npcidThe ID of the NPC
speedThe train speed to set

Returns​

Returns true if the operation was successful, false otherwise.

Examples​

public OnPlayerCommandText(playerid, cmdtext[])
{
if (!strcmp(cmdtext, "/settrainspeed ", true, 15))
{
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.");

new Float:speed = floatstr(cmdtext[15]);

NPC_SetVehicleTrainSpeed(npcid, speed);
SendClientMessage(playerid, 0x00FF00FF, "NPC %d train speed set to %.2f", npcid, speed);

return 1;
}
return 0;
}

Notes​

  • Only works with train vehicles (models 537, 538)
  • Use NPC_GetVehicleTrainSpeed to check current speed
  • Setting speed to 0 stops the train

No specific callbacks are triggered by this function.