getAttachedElements | Multi Theft Auto: Wiki Skip to content

getAttachedElements

Client-side
Server-side
Shared

Manual Review Required

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


This function returns a table of all the elements attached to the specified element

OOP Syntax Help! I don't understand this!

  • Method:element:getAttachedElements(...)

Syntax

table getAttachedElements ( element theElement )
Required Arguments
  • theElement: The element which you require the information from.

Returns

  • table: value

Returns a table of all the elements attached to the specified element.

Code Examples

shared
-- Print a list of all the players attached to the specified element
local Inf = getElementByID ( "infernus1" )
local attachedElements = getAttachedElements ( Inf )
if ( attachedElements ) then -- if we got the table
local attachedElementsList = "none"
-- Loop through the table
for ElementKey, ElementValue in ipairs ( attachedElements ) do
-- add their name to the list
if ( getElementType ( ElementValue ) == "player" ) then
if ( attachedElementsList == "none" ) then
attachedElementsList = getPlayerName ( ElementValue )
else
attachedElementsList = attachedElementsList .. ", " .. getPlayerName ( ElementValue )
end
end
end
outputConsole ( "Players attached to the infernus: " .. attachedElementsList )
end

See Also

Element Functions