setVehicleStraightLineDistance
Tune GTA's built-in straight-line distance value for a vehicle's native autopilot, as used by original mission driving.
Syntax
bool setVehicleStraightLineDistance(vehicle theVehicle, int distance)GTA task mapping
04E0 This does not create a CTask. It writes CAutoPilot::m_nStraightLineDistance, the byte used by GTA's vehicle AI.
Arguments
theVehiclevehicleVehicle controlled by this client.
distanceintNative autopilot value from 0 through 255.
Returns
true when the locally owned vehicle stored the value; false for an observer, invalid vehicle, or value outside 0..255.
Ownership and lifecycle
Door-lock, tyre-burst, physical-proof, and load-collision policies live on the MTA vehicle, apply immediately when its GTA instance is streamed, and are reapplied after local native recreation. They are client-local, last-writer-wins policies rather than resource-owned leases.
- The value survives stream-out and native vehicle recreation on this client.
- This is a low-level GTA autopilot setting, not a world distance in metres. Save and restore the previous value when a task ends.
Example
local previous = getVehicleStraightLineDistance(missionVehicle)assert(setVehicleStraightLineDistance(missionVehicle, 80))
-- Restore it after the mission task.if previous ~= false then setVehicleStraightLineDistance(missionVehicle, previous)endWhere this comes from
Continue exploring
← Back to the SA:O Lua API · How Native story vehicle state works →