Skip to main content

Fix Car Bump Boosting

Fix the curb-boosting exploit by enabling the CF_USE_DOWNFORCE_BIAS advanced flag via vehicle handlinghandling.metaXML file that defines vehicle physics properties including speed, acceleration, braking, traction, and suspension behavior..

Usage

Call this code when someone enters a vehicle:

local OR, XOR, AND = 1, 3, 4
local function bitOper(flag, checkFor, oper)
local result, mask, sum = 0, 2 ^ 31
repeat
sum, flag, checkFor = flag + checkFor + mask, flag % mask, checkFor % mask
result, mask = result + mask * oper % (sum - flag - checkFor), mask / 2
until mask < 1
return result
end

local function addDownforceFlag(vehicle)
local adv_flags = GetVehicleHandlingInt(vehicle, 'CCarHandlingData', 'strAdvancedFlags')
local hasDownforceFlag = bitOper(adv_flags, 134217728, AND) == 134217728

-- Remove flags 512 and 2048 if present
if not hasDownforceFlag then
adv_flags = bitOper(adv_flags, 134217728, OR)
end

local newFlags = math.floor(adv_flags)
SetVehicleHandlingField(vehicle, 'CCarHandlingData', 'strAdvancedFlags', newFlags)
end

How it works

This adds the strAdvancedFlags flag CF_USE_DOWNFORCE_BIAS. From the game docs:

Changes the way Downforce and spoiler tuning works, uses the setup found on Open-Wheel class vehicles in the vanilla game. Each spoiler/bumper tuning has to be given AdvancedData values to affect downforce. Adjusts initial downforce from fDownforceModifier. 'Curb - boosting' seems to be nullified. Previously known as _AF_DOWNFORCE_KERBFIX

warning

All vehicles must have the CCarHandlingData field already defined or else FiveMFiveMA multiplayer modification framework for Grand Theft Auto V, enabling custom multiplayer servers with modding support. will NOT be able to set the advanced flagsstrAdvancedFlagsBitfield in CCarHandlingData that controls advanced vehicle behavior including downforce bias, traction control, and suspension flags.. You do not have to define strAdvancedFlags — just CCarHandlingData:

<Item type="CCarHandlingData"> </Item>

Or if it doesn't have sub-handlinghandling.metaXML file that defines vehicle physics properties including speed, acceleration, braking, traction, and suspension behavior.:

<SubHandlingData>
<Item type="CCarHandlingData"></Item>
</SubHandlingData>