IsElementAttached: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
 
mNo edit summary
Line 37: Line 37:


==See Also==
==See Also==
<!-- Change FunctionArea to the area that this function is in on the main function list page, e.g. Server, Player, Vehicle etc -->
{{Element_functions}}
{{Element_functions}}
[[Category:Incomplete]] -- leave this unless you complete the function

Revision as of 14:44, 20 June 2007

This functions checks whether or not an element is attached to another element.

Syntax

bool isElementAttached ( theElement )

Required Arguments

  • theElement: The element to check for attachment.

Returns

Returns true if the specified element is attached to another element, false if it is not attached or if an improper argument is passed.

Example

This examples checks if a player is attached to anything when they enter a console command:

-- add a command handler for 'amiattached' to call the function 'consoleIsPlayerAttached':
addCommandHandler ( "amiattached", "consoleIsPlayerAttached" )
function consoleIsPlayerAttached ( player, command )
   if ( player ) then -- if a player triggered this command
      local status = isElementAttached ( player ) -- call the function and store it's result in the 'status' variable
      if ( status ) then -- if the function returned true, tell the player he is attached to something
         outputConsole ( "You are attached to an element!", player )
      else -- if the function returned false, tell the player he is not attached to anything
         outputConsole ( "You are not attached to an element.", player )
      end
   end
end

See Also