ServersYour serverFor creatorsForumFAQDocumentationSecurity
Download the launcher
  1. Documentation
  2. Shared functions
  3. setVehicleHandling

Function

setVehicleHandling

Server and clientVehiclesIdentical to MTA:SA

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, or nil = factory handling. Unknown fields in a table are skipped.
valueany, optional = nil
The field's new value (a number; centerOfMass is an { x, y, z } table). nil removes 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