GetElementAttachedTo

From Multi Theft Auto: Wiki
Revision as of 20:00, 1 January 2007 by Kevuwk (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

This function returns an element from the specified ID.

Syntax

element getElementAttachedTo ( element theElement )  

Required Arguments

  • theElement: The element you require the information for.

Returns

Returns the element that the chosen element is attached to, or false if the element isn't attached to another element.

Example

This example assigns the element that the specified element is attached to into attached.

addEventHandler ( "onConsole", root, "onConsole" )
function onConsole ( text )
  if ( getElementType ( source ) == "player" ) then
    command = gettok ( text, 1, 32 )  
    if ( command == "getattached" ) then
      attached = getElementAttachedTo ( source )
      if ( attached ) then
        outputConsole ( "element type: " .. getElementType ( attached ) ) -- possible output
      else
        outputConsole ( "not attached to an element" ) -- display error
      end
    end
  end
end

See Also