GetAttachedElements: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
m (fix oop syntax)
 
(5 intermediate revisions by 4 users not shown)
Line 7: Line 7:
table getAttachedElements ( element theElement )
table getAttachedElements ( element theElement )
</syntaxhighlight>
</syntaxhighlight>
{{OOP||[[element]]:getAttachedElements||}}


===Required Arguments===
===Required Arguments===
Line 27: Line 28:
       if ( getElementType ( ElementValue ) == "player" ) then
       if ( getElementType ( ElementValue ) == "player" ) then
         if ( attachedElementsList == "none" ) then
         if ( attachedElementsList == "none" ) then
           attachedElementsList = getClientName ( ElementValue )
           attachedElementsList = getPlayerName ( ElementValue )
         else
         else
           attachedElementsList = attachedElementsList .. ", " .. getClientName ( ElementValue )
           attachedElementsList = attachedElementsList .. ", " .. getPlayerName ( ElementValue )
         end
         end
       end
       end

Latest revision as of 14:50, 1 January 2015

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

Syntax

table getAttachedElements ( element theElement )

OOP Syntax Help! I don't understand this!

Method: element:getAttachedElements(...)


Required Arguments

  • theElement: The element which you require the information from.

Returns

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

Example

Click to collapse [-]
Server
-- 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