GetElementAttachedTo: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
(No difference)

Revision as of 20:00, 1 January 2007

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

Shared