GetElementAttachedTo: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
Line 21: Line 21:
     local attached = getElementAttachedTo ( thePlayer )
     local attached = getElementAttachedTo ( thePlayer )
     if ( attached ) then
     if ( attached ) then
         outputConsole ( getClientName(thePlayer) .. " is attached to a " .. getElementType(attached) )
         outputConsole ( getPlayerName(thePlayer) .. " is attached to a " .. getElementType(attached) )
     else
     else
         outputConsole ( getClientName(thePlayer) .. " is not attached to an element" )
         outputConsole ( getPlayerName(thePlayer) .. " is not attached to an element" )
     end
     end
end
end

Revision as of 12:13, 27 August 2009

This function determines the element that the specified element is attached to.

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

Click to collapse [-]
Server

This example defines a console command that outputs the type of the element that the player is attached to.

function getAttached ( thePlayer )
    local attached = getElementAttachedTo ( thePlayer )
    if ( attached ) then
        outputConsole ( getPlayerName(thePlayer) .. " is attached to a " .. getElementType(attached) )
    else
        outputConsole ( getPlayerName(thePlayer) .. " is not attached to an element" )
    end
end
addCommandHandler ( "getattached", getAttached )

See Also

Shared