GetVehicleComponents
From Multi Theft Auto: Wiki
This function gets a table of the components currently on a vehicle.
Syntax
table getVehicleComponents ( vehicle theVehicle )
OOP Syntax Help! I don't understand this!
- Method: vehicle:getComponents(...)
- Variable: .components
Required Arguments
- theVehicle: The vehicle you wish to get the components of.
Returns
Returns a table containing the name of the component as the key and visibility flag of that component as the value
Example
Click to collapse [-]
ClientaddCommandHandler ( "gvc", function ( ) local theVehicle = getPedOccupiedVehicle ( localPlayer ) if ( theVehicle ) then for k in pairs ( getVehicleComponents ( theVehicle ) ) do outputChatBox ( k ) end end end )
Click to collapse [-]
ClientThis example draw all components names on the player screen.
addEventHandler ( "onClientRender", root, function() if isPedInVehicle ( localPlayer ) and getPedOccupiedVehicle ( localPlayer ) then local veh = getPedOccupiedVehicle ( localPlayer ) for v in pairs ( getVehicleComponents(veh) ) do local x,y,z = getVehicleComponentPosition ( veh, v, "world" ) local wx,wy,wz = getScreenFromWorldPosition ( x, y, z ) if wx and wy then dxDrawText ( v, wx -1, wy -1, 0 -1, 0 -1, tocolor(0,0,0), 1, "default-bold" ) dxDrawText ( v, wx +1, wy -1, 0 +1, 0 -1, tocolor(0,0,0), 1, "default-bold" ) dxDrawText ( v, wx -1, wy +1, 0 -1, 0 +1, tocolor(0,0,0), 1, "default-bold" ) dxDrawText ( v, wx +1, wy +1, 0 +1, 0 +1, tocolor(0,0,0), 1, "default-bold" ) dxDrawText ( v, wx, wy, 0, 0, tocolor(0,255,255), 1, "default-bold" ) end end end end)
by FusioN.
See Also
FROM VERSION 1.5.7 r19626 ONWARDS
- attachTrailerToVehicle
- blowVehicle
- createVehicle
- detachTrailerFromVehicle
- fixVehicle
- getHeliBladeCollisionsEnabled
- getHelicopterRotorSpeed
- getOriginalHandling
- getTrainDirection
- getTrainPosition
- getTrainSpeed
FROM VERSION 1.6 r7485 ONWARDS
- getVehicleAdjustableProperty
- getVehicleColor
- getVehicleCompatibleUpgrades
- getVehicleComponentPosition
- getVehicleComponentRotation
- getVehicleComponentScale
- getVehicleComponentVisible
- getVehicleComponents
- getVehicleController
- getVehicleCurrentGear
- getVehicleDoorOpenRatio
- getVehicleDoorState
- getVehicleEngineState
- getVehicleGravity
- getVehicleHandling
- getVehicleHeadLightColor
- getVehicleLandingGearDown
- getVehicleLightState
- getVehicleMaxPassengers
- getVehicleModelDummyPosition
- getVehicleModelExhaustFumesPosition
- getVehicleModelFromName
- getVehicleName
- getVehicleNameFromModel
- getVehicleNitroCount
- getVehicleNitroLevel
- getVehicleOccupant
- getVehicleOccupants
- getVehicleOverrideLights
- getVehiclePaintjob
- getVehiclePanelState
- getVehiclePlateText
- getVehicleSirens
- getVehicleSirensOn
- getVehicleSirenParams
- getVehicleTowedByVehicle
- getVehicleTowingVehicle
- getVehicleTurretPosition
- getVehicleType
- getVehicleUpgradeOnSlot
- getVehicleUpgradeSlotName
- getVehicleUpgrades
- getVehicleVariant
- getVehicleWheelStates
- isTrainChainEngine
- isTrainDerailable
- isTrainDerailed
- isVehicleBlown
- isVehicleDamageProof
- isVehicleFuelTankExplodable
- isVehicleLocked
- isVehicleNitroActivated
- isVehicleNitroRecharging
- isVehicleOnGround
- isVehicleTaxiLightOn
- isVehicleWheelOnGround
- isVehicleWindowOpen
- removeVehicleUpgrade
- resetVehicleComponentPosition
- resetVehicleComponentRotation
- resetVehicleComponentScale
- setHeliBladeCollisionsEnabled
- setHelicopterRotorSpeed
- setTrainDerailable
- setTrainDerailed
- setTrainDirection
- setTrainPosition
- setTrainSpeed
FROM VERSION 1.6 r7485 ONWARDS
- setVehicleAdjustableProperty
- setVehicleColor
- setVehicleComponentPosition
- setVehicleComponentRotation
- setVehicleComponentScale
- setVehicleComponentVisible
- setVehicleDamageProof
- setVehicleDirtLevel
- setVehicleDoorOpenRatio
- setVehicleDoorState
- setVehicleDoorsUndamageable
- setVehicleEngineState
- setVehicleFuelTankExplodable
- setVehicleGravity
- setVehicleHandling
- setVehicleHeadLightColor
- setVehicleLandingGearDown
- setVehicleLightState
- setVehicleLocked
- setVehicleModelDummyPosition
- setVehicleModelExhaustFumesPosition
- setVehicleNitroActivated
- setVehicleNitroCount
- setVehicleNitroLevel
- setVehicleOverrideLights
- setVehiclePaintjob
- setVehiclePanelState
- setVehiclePlateText
- setVehicleSirens
- setVehicleSirensOn
- setVehicleTaxiLightOn