SetVehicleHandling
Jump to navigation
Jump to search
This function is used to change the handling data of a vehicle.
Syntax
bool setVehicleHandling ( element theVehicle, string property, var value )
Required Arguments
- theVehicle: The vehicle you wish to set the handling of.
- property: The property you wish to set the handling of the vehicle to.
http://web.archive.org/web/20140223160252/http://projectcerbera.com/gta/sa/tutorials/handling
Property | Value | Minimum value | Maximum value | Notes |
---|---|---|---|---|
mass | Float | 1.0 | 100000.0 | |
turnMass | Float | 0.0 | 1000000.0 | |
dragCoeff | Float | -200.0 | 200.0 | |
centerOfMass | Table = { [1]=posX, [2]=posY, [3]=posZ } (floats) | -10.0 | 10.0 | Get returns a table, set needs a table. |
percentSubmerged | Integer | 1 | 99999 | |
tractionMultiplier | Float | -100000.0 | 100000.0 | |
tractionLoss | Float | 0.0 | 100.0 | |
tractionBias | Float | 0.0 | 1.0 | |
numberOfGears | Integer | 1 | 5 | |
maxVelocity | Float | 0.1 | 200000.0 | |
engineAcceleration | Float | 0.0 | 100000.0 | |
engineInertia | Float | -1000.0 | 1000.0 | Inertia of 0 can cause a LSOD. (Unable to divide by zero) |
driveType | String | N/A | N/A | Use 'rwd', 'fwd' or 'awd'. |
engineType | String | N/A | N/A | Use 'petrol', 'diesel' or 'electric'. |
brakeDeceleration | Float | 0.1 | 100000.0 | |
brakeBias | Float | 0.0 | 1.0 | |
ABS | Boolean | true | false | Has no effect. |
steeringLock | Float | 0.0 | 360.0 | |
suspensionForceLevel | Float | 0.0 | 100.0 | |
suspensionDamping | Float | 0.0 | 100.0 | |
suspensionHighSpeedDamping | Float | 0.0 | 600.0 | |
suspensionUpperLimit | Float | -50.0 | 50.0 | Can't be equal to suspensionLowerLimit. |
suspensionLowerLimit | Float | -50.0 | 50.0 | Can't be equal to suspensionUpperLimit. |
suspensionFrontRearBias | Float | 0.0 | 1.0 | Hardcoded maximum is 3.0, but values above 1.0 have no effect. |
suspensionAntiDiveMultiplier | Float | 0.0 | 30.0 | |
seatOffsetDistance | Float | -20.0 | 20.0 | |
collisionDamageMultiplier | Float | 0.0 | 10.0 | |
monetary | Integer | 0 | 230195200 | Get works, set is disabled. |
modelFlags | Hexadecimal/Decimal | N/A | N/A | Property uses a decimal value, generated by a hexadecimal value. Either use 0x12345678 or tonumber ( "0x12345678" ). See projectcerbera for possible values. |
handlingFlags | Hexadecimal/Decimal | N/A | N/A | Property uses a decimal value, generated by a hexadecimal value. Either use 0x12345678 or tonumber ( "0x12345678" ). See projectcerbera for possible values. |
headLight | String | N/A | N/A | Get works, set is disabled. Available values: 'long', 'small', 'big', 'tall'. |
tailLight | String | N/A | N/A | Get works, set is disabled. Available values: 'long', 'small', 'big', 'tall'. |
animGroup | Integer | ?? | ?? | Get works, set is disabled due to people not knowing this property was vehicle-based and caused crashes. |
- value: The value of the property you wish to set the handling of the vehicle to.
Returns
Returns true if the handling was set successfully, false otherwise. See below a list of valid propertys and their required values:
Notes
for functionality reasons suspension modification is disabled on monster trucks, trains and boats.
Example
function massChange ( me, command, mass ) mass = tonumber ( mass ) -- Convert mass to a number local veh = getPedOccupiedVehicle ( me ) -- Get the player's vehicle if mass and veh then -- If valid mass and in a vehicle local success = setVehicleHandling ( veh, "mass", mass ) -- Set the vehicle's mass, and check if successful if success then -- If successful outputChatBox ( "Your vehicle's mass has been changed to: "..mass.." kg", me, 0, 255, 0 ) -- Notify the player of success else -- Too bad failure is still an option outputChatBox ( "Setting mass failed. It's probably above or below allowed limits", me, 255, 0, 0 ) -- Notify the player of failure, and give a possible reason end elseif not veh then -- If not in a vehicle outputChatBox ( "You're not in a vehicle", me, 255, 0, 0 ) -- Tell the player; He / she obviously doesn't know elseif not mass then -- If not a valid mass outputChatBox ( "Syntax: /changemass [mass]", me, 255, 0, 0 ) -- Tell the player the proper syntax end end addCommandHandler ( "changemass", massChange )
Click to collapse [-]
ServerThis example script changes the handling of all Infernus.
function handlingChange () for i,v in ipairs(getElementsByType("vehicle")) do if getElementModel(v) == 541 then setVehicleHandling(v, "mass", 1890) setVehicleHandling(v, "turnMass", 3780) setVehicleHandling(v, "dragCoeff", 0.7) setVehicleHandling(v, "centerOfMass", posX, 0.0, posY, 0.1, posZ, -0.2) setVehicleHandling(v, "percentSubmerged", 75) setVehicleHandling(v, "tractionMultiplier", 0.70) setVehicleHandling(v, "tractionLoss", 0.90) setVehicleHandling(v, "tractionBias", 0.50) setVehicleHandling(v, "numberOfGears", 5) setVehicleHandling(v, "maxVelocity", 407) setVehicleHandling(v, "engineAcceleration", 50) setVehicleHandling(v, "engineInertia", 10) setVehicleHandling(v, "driveType", "awd") setVehicleHandling(v, "engineType", "petrol") setVehicleHandling(v, "brakeDeceleration", 11) setVehicleHandling(v, "brakeBias", 0.45) setVehicleHandling(v, "ABS", false) setVehicleHandling(v, "steeringLock", 30) setVehicleHandling(v, "suspensionForceLevel", 0.80) setVehicleHandling(v, "suspensionDamping", 0.20) setVehicleHandling(v, "suspensionHighSpeedDamping", 0.0) setVehicleHandling(v, "suspensionUpperLimit", 0.10) setVehicleHandling(v, "suspensionLowerLimit", -0.09) setVehicleHandling(v, "suspensionFrontRearBias", 0.5) setVehicleHandling(v, "suspensionAntiDiveMultiplier", 0.6) setVehicleHandling(v, "seatOffsetDistance", 0.3) setVehicleHandling(v, "collisionDamageMultiplier", 0.50) setVehicleHandling(v, "monetary", 1460000) setVehicleHandling(v, "modelFlags", 0xC0222004) setVehicleHandling(v, "handlingFlags", 0x1400000) setVehicleHandling(v, "headLight", 1) setVehicleHandling(v, "tailLight", 1) setVehicleHandling(v, "animGroup", 0) end end end addEventHandler ( "onPlayerVehicleEnter", getRootElement(), handlingChange )
See other vehicle functions
- addVehicleUpgrade
- attachTrailerToVehicle
- blowVehicle
- createVehicle
- detachTrailerFromVehicle
- fixVehicle
- getOriginalHandling
- getTrainDirection
- getTrainPosition
- getTrainSpeed
- getTrainTrack
- getVehicleColor
- getVehicleCompatibleUpgrades
- getVehicleController
- getVehicleDoorOpenRatio
- getVehicleDoorState
- getVehicleEngineState
- getVehicleHandling
- getVehicleHeadLightColor
- getVehicleLandingGearDown
- getVehicleLightState
- getVehicleMaxPassengers
- getVehicleModelFromName
- getVehicleName
- getVehicleNameFromModel
- getVehicleOccupant
- getVehicleOccupants
- getVehicleOverrideLights
- getVehiclePaintjob
- getVehiclePanelState
- getVehiclePlateText
- getVehicleSirenParams
- getVehicleSirens
- getVehicleSirensOn
- getVehicleTowedByVehicle
- getVehicleTowingVehicle
- getVehicleTurretPosition
- getVehicleType
- getVehicleUpgradeOnSlot
- getVehicleUpgradeSlotName
- getVehicleUpgrades
- getVehicleVariant
- getVehicleWheelStates
- isTrainDerailable
- isTrainDerailed
- isVehicleBlown
- isVehicleDamageProof
- isVehicleFuelTankExplodable
- isVehicleLocked
- isVehicleOnGround
- isVehicleTaxiLightOn
- removeVehicleUpgrade
- setTrainDerailable
- setTrainDerailed
- setTrainDirection
- setTrainPosition
- setTrainSpeed
- setTrainTrack
- setVehicleColor
- setVehicleDamageProof
- setVehicleDoorOpenRatio
- setVehicleDoorState
- setVehicleDoorsUndamageable
- setVehicleEngineState
- setVehicleFuelTankExplodable
- setVehicleHandling
- setVehicleHeadLightColor
- setVehicleLandingGearDown
- setVehicleLightState
- setVehicleLocked
- setVehicleOverrideLights
- setVehiclePaintjob
- setVehiclePanelState
- setVehiclePlateText
- setVehicleSirens
- setVehicleSirensOn
- setVehicleTaxiLightOn
- setVehicleTurretPosition
- setVehicleVariant
- setVehicleWheelStates