GetVehicleComponents: Difference between revisions
Jump to navigation
Jump to search
mNo edit summary |
m (mistake) |
||
(6 intermediate revisions by 4 users not shown) | |||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
{{Client function}} | {{Client function}} | ||
{{New feature/item| | {{New feature/item|3.0131|1.3.1|4748| | ||
This function gets a table of the components currently on a [[vehicle]]. | This function gets a table of the components currently on a [[vehicle]]. | ||
}} | }} | ||
==Syntax== | ==Syntax== | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua">table getVehicleComponents ( vehicle theVehicle )</syntaxhighlight> | ||
table getVehicleComponents ( vehicle theVehicle ) | {{OOP||[[vehicle]]:getComponents|components}} | ||
</syntaxhighlight> | |||
===Required Arguments=== | ===Required Arguments=== | ||
*'''theVehicle:''' The [[vehicle]] you wish to get the components of. | *'''theVehicle:''' The [[vehicle]] you wish to get the [[Vehicle_Components|components]] of. | ||
===Returns=== | ===Returns=== | ||
Line 30: | Line 29: | ||
) | ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
</section> | |||
<section name="Client" class="client" show="true"> | |||
This example draw all components names on the player screen. | |||
<syntaxhighlight lang="lua"> | |||
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) | |||
</syntaxhighlight> | |||
by '''FusioN'''. | |||
</section> | </section> | ||
==See Also== | ==See Also== | ||
{{Client_vehicle_functions}} | {{Client_vehicle_functions}} |
Latest revision as of 05:04, 15 April 2017
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
- areVehicleLightsOn
- getHeliBladeCollisionsEnabled
- getHelicopterRotorSpeed
- getVehicleAdjustableProperty
- getVehicleComponentPosition
- getVehicleComponentRotation
- getVehicleComponents
- getVehicleComponentScale
- getVehicleComponentVisible
- getVehicleCurrentGear
- getVehicleDummyPosition
- getVehicleGravity
- getVehicleLandingGearDown
- getVehicleModelDummyDefaultPosition
- getVehicleModelDummyPosition
- getVehicleModelExhaustFumesPosition
- getVehicleModelWheelSize
- getVehicleNitroCount
- getVehicleNitroLevel
- getVehicleWheelFrictionState
- getVehicleWheelScale
- isTrainChainEngine
- isVehicleNitroActivated
- isVehicleNitroRecharging
- isVehicleOnGround
- isVehicleWheelOnGround
- isVehicleWindowOpen
- resetVehicleComponentPosition
- resetVehicleComponentRotation
- resetVehicleComponentScale
- resetVehicleDummyPositions
- setHeliBladeCollisionsEnabled
- setHelicopterRotorSpeed
- setVehicleAdjustableProperty
- setVehicleComponentPosition
- setVehicleComponentRotation
- setVehicleComponentScale
- setVehicleComponentVisible
- setVehicleDummyPosition
- setVehicleGravity
- setVehicleLandingGearDown
- setVehicleModelDummyPosition
- setVehicleModelExhaustFumesPosition
- setVehicleModelWheelSize
- setVehicleNitroActivated
- setVehicleNitroCount
- setVehicleNitroLevel
- setVehicleWheelScale
- setVehicleWheelStates
- setVehicleWindowOpen
- Shared
- 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