getVehicleComponentPosition | Multi Theft Auto: Wiki Skip to content

getVehicleComponentPosition

Client-side
Server-side
Shared

Pair: setVehicleComponentPosition

Manual Review Required

Please finish this page using the corresponding Old Wiki article. Go to Contribution guidelines for more information.


This function gets the component position of a vehicle. The vehicle must be streamed in.

OOP Syntax Help! I don't understand this!

  • Method:vehicle:getComponentPosition(...)

Syntax

float,​ float,​ float getVehicleComponentPosition ( vehicle theVehicle, string theComponent, [ string base = "root" ] )
Required Arguments
  • theVehicle: The vehicle you wish to get component position of.
  • theComponent: A vehicle component (this is the frame name from the model file of the component you wish to modify)
Optional Arguments

NOTE: When using optional arguments, you might need to supply all arguments before the one you wish to use.

  • base (default: "root"): A string representing what the returned position is relative to. It can be one of the following values: parent: The position is relative to the parent component. root: The position is relative to the root component. world: The position is a world position.

Returns

  • float: x
  • float: y
  • float: z

Returns three floats indicating the position of the component, x , y and z respectively.

Code Examples

shared
addCommandHandler("vcp", -- short for 'vehicle component position'
function()
local theVeh = getPedOccupiedVehicle(localPlayer)
local getComponent = getVehicleComponents(theVeh) -- returns table with all the components of the vehicle
if (theVeh) then
for k in pairs (getComponent) do
local x, y, z = getVehicleComponentPosition(theVeh, k)
outputChatBox("Position of "..k.." is"..x.." "..y.." "..z)
end
end
end
)

See Also

Vehicle Functions