Skip to content

setVehicleStraightLineDistance

Client-side

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

NATIVE GTA BEHAVIOR 04E0
No CTask is created

This does not create a CTask. It writes CAutoPilot::m_nStraightLineDistance, the byte used by GTA's vehicle AI.

Arguments

theVehiclevehicle

Vehicle controlled by this client.

distanceint

Native 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.

Important behavior
  • 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)
end

Where this comes from

RELATED SA:O APIS

Continue exploring

Read the system guide →