GetVehicleHandling: Difference between revisions
Jump to navigation
Jump to search
m (added OOP syntax) |
mNo edit summary |
||
(2 intermediate revisions by 2 users not shown) | |||
Line 5: | Line 5: | ||
==Syntax== | ==Syntax== | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
mixed getVehicleHandling ( element theVehicle, [ string property ] ) | |||
</syntaxhighlight> | </syntaxhighlight> | ||
{{OOP||[[vehicle]]:getHandling|handling}} | {{OOP||[[vehicle]]:getHandling|handling}} | ||
===Required Arguments=== | ===Required Arguments=== | ||
*'''theVehicle:''' the vehicle you wish to get the handling data of. | *'''theVehicle:''' the vehicle you wish to get the handling data of. | ||
===Optional Arguments=== | |||
{{OptionalArg}} | |||
{{New feature/item|3.0161|1.6.0|22649| | |||
*'''property''' the property you want to get.}} | |||
===Returns=== | ===Returns=== | ||
Returns a ''table'' containing all the handling data, ''false'' otherwise. Here's a list of valid table properties and what they return: | Returns a ''table'' containing all the handling data, ''false'' otherwise. If a property is specified, it returns the value of the specific property. Here's a list of valid table properties and what they return: | ||
{{Handling Properties}} | {{Handling Properties}} | ||
Latest revision as of 11:05, 31 July 2024
This function returns a table of the current vehicle handling data.
Syntax
mixed getVehicleHandling ( element theVehicle, [ string property ] )
OOP Syntax Help! I don't understand this!
- Method: vehicle:getHandling(...)
- Variable: .handling
Required Arguments
- theVehicle: the vehicle you wish to get the handling data of.
Optional Arguments
NOTE: When using optional arguments, you might need to supply all arguments before the one you wish to use. For more information on optional arguments, see optional arguments.
Returns
Returns a table containing all the handling data, false otherwise. If a property is specified, it returns the value of the specific property. Here's a list of valid table properties and what they return:
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 & ClientThis example creates a new function called getVehicleHandlingProperty, which simulates the previous syntax of this function.
function getVehicleHandlingProperty ( element, property ) if isElement ( element ) and getElementType ( element ) == "vehicle" and type ( property ) == "string" then -- Make sure there's a valid vehicle and a property string local handlingTable = getVehicleHandling ( element ) -- Get the handling as table and save as handlingTable local value = handlingTable[property] -- Get the value from the table if value then -- If there's a value (valid property) return value -- Return it end end return false -- Not an element, not a vehicle or no valid property string. Return failure end
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