Zum Inhalt springen

Driving-Style-Rechner

Kombinier Fahrzeug-Driving-Flags (für Autos anhalten, Peds ausweichen, kürzesten Weg nehmen…) zu dem einen Integer, den TaskVehicleDriveToCoord, TaskVehicleDriveWander und SetDriveTaskDrivingStyle erwarten.

Dieses Tool und seine Hinweise sind vorerst auf Englisch.

RechnerNatives, FlagsZur Doku

32 flags · 7 set

Presets
Values used in Rockstar's scripts (39)

Driving style

Decimal
Hex
Binary
Set flags
Expression

StopForVehicles | StopForPeds | SteerAroundStationaryVehicles | SteerAroundObjects | StopAtTrafficLights | UseShortCutLinks | ChangeLanesAroundObstructions

Snippet options

Task
Driver
Destination
driving_style.lua
-- StopForVehicles | StopForPeds | SteerAroundStationaryVehicles
--   | SteerAroundObjects | StopAtTrafficLights | UseShortCutLinks
--   | ChangeLanesAroundObstructions
local drivingStyle = 786603
local speed = 20.0 -- m/s (72 km/h, 45 mph)
local stopRange = 8.0 -- stop this many metres from the target

CreateThread(function()
    local ped = PlayerPedId()
    local vehicle = GetVehiclePedIsIn(ped, false)
    if vehicle == 0 or GetPedInVehicleSeat(vehicle, -1) ~= ped then
        print("You need to be the driver of a vehicle.")
        return
    end

    local blip = GetFirstBlipInfoId(8) -- 8 = waypoint
    if not DoesBlipExist(blip) then
        print("Set a waypoint on the map first.")
        return
    end
    local target = GetBlipInfoIdCoord(blip)

    SetDriverAbility(ped, 1.0)        -- 0.0 - 1.0, higher = better driving
    SetDriverAggressiveness(ped, 0.0) -- 0.0 - 1.0

    -- p6 is unused, p10 is the straight-line distance (1.0 is fine).
    TaskVehicleDriveToCoord(ped, vehicle, target.x, target.y, target.z, speed, 0, GetEntityModel(vehicle), drivingStyle, stopRange, 1.0)

    -- Wait until we arrive (or the vehicle is gone).
    while DoesEntityExist(vehicle) and #(GetEntityCoords(vehicle) - target) > stopRange + 5.0 do
        Wait(500)
    end
    print("Arrived")

    -- Take back control any time with: ClearPedTasks(ped)
end)

How driving styles work

A driving style is a 32-bit integer where every bit switches one AI behaviour on or off. You build it by adding the values of the flags you want (or OR-ing them together), then pass it to a driving task such asTaskVehicleDriveToCoord, TaskVehicleDriveToCoordLongrange orTaskVehicleDriveWander. To change the style of a task that is already running, useSetDriveTaskDrivingStyle(ped, style).

-- stop for cars + stop for peds + steer around stationary cars + steer around objects
-- + stop at lights + shortcut links + change lanes = 786603 ("normal")
local style = 1 | 2 | 8 | 32 | 128 | 262144 | 524288
TaskVehicleDriveWander(ped, vehicle, 20.0, style)

Decoding a value

Paste any number into Decode a value to see which flags it contains. Negative numbers (signed int32, as some dumps print them), 0x hex, 0b binary and expressions like1 | 2 | 128 all work. The current value is kept in the URL (?v=) so you can share it.

Tips

  • Speed is in metres per second. 20.0 is about 72 km/h (45 mph).
  • SetDriverAbility and SetDriverAggressiveness (0.0 to 1.0) change how well and how hard the ped drives, independent of the style.
  • NPC drivers give up or react to gunfire unless you call SetBlockingOfNonTemporaryEvents(ped, true).
  • Bits marked unknown are not used in Rockstar's scripts. Bit 31 (StopAtDestination) makes the signed value negative, which is fine: natives take it as an int32.
  • DontSteerAroundPlayerPed, AvoidRestrictedAreas and the other newer names come from the official enum. Older calculators labelled some bits differently ("use blinkers", "reckless"); those names are listed as "also known as".

Flag names follow the eVehicleDrivingFlags enum on docs.fivem.net. Idea and the list of values Rockstar uses come from Vespura's originaldriving style calculator.