SetModelHandling

From Multi Theft Auto: Wiki
Jump to navigation Jump to search

This function is used to change the handling data of all vehicles of a specified model.

Syntax

bool setModelHandling ( int modelId, string property, var value ) 

Required Arguments

  • modelId: The vehicle model you wish to set the handling of.
  • property: The property you wish to set the handling of the vehicle to, or nil if you want to reset the all the handling properties.
  • value: The value of the models's handling property you wish to set, or nil if you want to reset the handling property to its default value.

Returns

Returns true if the handling was set successfully, false otherwise.


Handling Properties

See below a list of valid properties and their required values:

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.


Example

Click to collapse [-]
Server

This example script changes the handling of all Bullet.

function handlingChange()
	local modelId = 541
	setModelHandling(modelId, "mass", 1890)
	setModelHandling(modelId, "turnMass", 3780)
	setModelHandling(modelId, "dragCoeff", 0.7)
	setModelHandling(modelId, "centerOfMass", {0.0, 0.1, -0.2} )
	setModelHandling(modelId, "percentSubmerged", 75)
	setModelHandling(modelId, "tractionMultiplier", 0.70)
	setModelHandling(modelId, "tractionLoss", 0.90)
	setModelHandling(modelId, "tractionBias", 0.50)
	setModelHandling(modelId, "numberOfGears", 5)
	setModelHandling(modelId, "maxVelocity", 407)
	setModelHandling(modelId, "engineAcceleration", 50)
	setModelHandling(modelId, "engineInertia", 10)
	setModelHandling(modelId, "driveType", "awd")
	setModelHandling(modelId, "engineType", "petrol")
	setModelHandling(modelId, "brakeDeceleration", 11)
	setModelHandling(modelId, "brakeBias", 0.45)
	setModelHandling(modelId, "ABS", false)
	setModelHandling(modelId, "steeringLock", 30)
	setModelHandling(modelId, "suspensionForceLevel", 0.80)
	setModelHandling(modelId, "suspensionDamping", 0.20)
	setModelHandling(modelId, "suspensionHighSpeedDamping", 0.0)
	setModelHandling(modelId, "suspensionUpperLimit", 0.10)
	setModelHandling(modelId, "suspensionLowerLimit", -0.09)
	setModelHandling(modelId, "suspensionFrontRearBias", 0.5)
	setModelHandling(modelId, "suspensionAntiDiveMultiplier", 0.6)
	setModelHandling(modelId, "seatOffsetDistance", 0.3)
	setModelHandling(modelId, "collisionDamageMultiplier", 0.50)
	setModelHandling(modelId, "monetary", 1460000)
	setModelHandling(modelId, "modelFlags", 0xC0222004)
	setModelHandling(modelId, "handlingFlags", 0x1400000)
	setModelHandling(modelId, "headLight", 1)
	setModelHandling(modelId, "tailLight", 1)
	setModelHandling(modelId, "animGroup", 0)
end
addEventHandler("onResourceStart", resourceRoot, handlingChange)


This function will reset the handling of Bullet vehicles to its default state.

function resetHandling()
	local modelId = 541
	for k,_ in pairs(getModelHandling(modelId)) do
		setModelHandling(modelId, k, nil)
	end
end
addEventHandler("onResourceStop", resourceRoot, resetHandling)

Issues

Issue ID Description
#553 setModelHandling doesn't work with already created vehicles
#1198 "setModelHandling" function doesn't affect vehicles that have been changed using "setElementModel"

See other vehicle functions