- Documentation
- Shared functions
- setVehicleHandling
Function
setVehicleHandling
Changes the driving parameters (handling) of one vehicle for every player: mass, top speed, acceleration, grip, brakes, steering, suspension and other handling.cfg fields. The game gets its own copy of the handling entry for this car, so other vehicles of the model do not change. You can pass one field with a value, a whole table of fields, or nil to go back to the factory handling (including setModelHandling). Field names; the list: getHandlingFieldNames.
Syntax
bool setVehicleHandling(vehicle vehicle [, string/table propertyOrTable = nil, any value = nil])Arguments
vehiclevehicle- The vehicle.
propertyOrTablestring/table, optional = nil- Field name (e.g.
"maxVelocity","engineAcceleration","tractionMultiplier","mass","suspensionLowerLimit"), a{ field = value }table replacing all of the vehicle's changes, ornil= factory handling. Unknown fields in a table are skipped. valueany, optional = nil- The field's new value (a number;
centerOfMassis an{ x, y, z }table).nilremoves the change for that field.
Returns
true on success, false for an unknown field name.
Example
addCommandHandler("sport", function(player)
local vehicle = getPedOccupiedVehicle(player)
if not vehicle then return end
-- skala jak w handling.cfg: liczymy od wartosci fabrycznych modelu
local factory = getOriginalHandling(getElementModel(vehicle))
setVehicleHandling(vehicle, "maxVelocity", factory.maxVelocity * 1.15)
setVehicleHandling(vehicle, "engineAcceleration", factory.engineAcceleration * 1.3)
setVehicleHandling(vehicle, "tractionMultiplier", factory.tractionMultiplier * 1.1)
setVehicleHandling(vehicle, "driveType", "awd")
end)
Notes
Client. In a client script the handling applies for this player only. The driver computes the driving, so on a vehicle this player drives the change works while driving; it holds until the server changes this vehicle's handling.
Field types and scale. Numbers use the same scale as handling.cfg (what getOriginalHandling returns): e.g. the Elegy (562) has engineAcceleration = 28 and the LS police car (596) 25, so 18 makes a car WEAKER than stock. maxVelocity in km/h, mass in kg, brakeDeceleration as in the file (about 4-11), tractionMultiplier about 0.6-1.3. driveType is a string: "fwd" (front), "rwd" (rear), "awd" (4x4). engineType: "petrol", "diesel", "electric". ABS is true/false. handlingFlags and modelFlags are numbers (bits as hex in handling.cfg, e.g. 0x4000000). centerOfMass = { x, y, z }. Changing maxVelocity, engineAcceleration, numberOfGears, driveType or dragCoeff recomputes the gearbox the way the game does.
See also
getVehicleHandlingReturns a vehicle's full handling as the game uses it: factory values from handling.cfg, overridden by model settings (setModelHandling), and finally by this vehicle's changes (setVehicleHandling,setVehicleEngine). Works on both sides.setModelHandlingChanges the handling of every vehicle of a model at once, for every player, including vehicles created later. A single car's changes fromsetVehicleHandlingtake priority over the model setting.getHandlingFieldNamesReturns the names of all handling fields accepted bysetVehicleHandlingandsetModelHandling:mass,turnMass,dragCoeff,centerOfMass,percentSubmerged,tractionMultiplier,tractionLoss,tractionBias,numberOfGears,maxVelocity,engineAcceleration,engineInertia,driveType,engineType,brakeDeceleration,brakeBias,ABS,steeringLock, thesuspension*fields,seatOffsetDistance,collisionDamageMultiplier,monetary,modelFlags,handlingFlags,headLight,tailLight,animGroup.getOriginalHandlingReturns a model's factory handling straight from the game files (Definitive Edition handling.cfg), without any script changes. Works on both sides.