SetElementID: Difference between revisions
Jump to navigation
Jump to search
Line 21: | Line 21: | ||
for i=1,#players do | for i=1,#players do | ||
setElementID( players[i], "player" .. tostring(i) ) -- Loop the table and change the element IDs to 'player1', 'player2', 'player3'... | setElementID( players[i], "player" .. tostring(i) ) -- Loop the table and change the element IDs to 'player1', 'player2', 'player3'... | ||
outputDebugString( "Player[" .. i .. "] = " .. getElementID( players[i] ) ) -- Output the new element IDs to debugstring. | outputDebugString( "Player[" .. i .. "] = " .. getElementID( players[i] ) ) -- Output the new element IDs to debugstring. | ||
end | end |
Revision as of 19:52, 13 July 2012
This function sets the ID of an element to a string. This can be anything from an identifying number, to a name.
Syntax
bool setElementID ( element theElement, string name )
Required Arguments
- theElement: The element you want to set the ID of.
- name: The new ID for theElement.
Returns
This returns true if successful. It will return false if theElement is invalid, or does not exist, or if name is invalid, or is not a string.
Example
local players = getElementsByType( "player" ) -- Get a table of all players. for i=1,#players do setElementID( players[i], "player" .. tostring(i) ) -- Loop the table and change the element IDs to 'player1', 'player2', 'player3'... outputDebugString( "Player[" .. i .. "] = " .. getElementID( players[i] ) ) -- Output the new element IDs to debugstring. end
See Also
- attachElements
- createElement
- destroyElement
- detachElements
- getAttachedElements
- getElementAlpha
- getElementAttachedOffsets
- getElementAttachedTo
- getElementByIndex
- getElementByID
- getElementChild
- getElementChildren
- getElementChildrenCount
- getElementCollisionsEnabled
- getElementColShape
- getElementData
- getAllElementData
- hasElementData
- getElementDimension
- getElementHealth
- getElementID
- getElementInterior
- getElementMatrix
- getElementModel
- getElementParent
- getElementPosition
- getElementRotation
- getElementsByType
- getElementsWithinColShape
- getElementsWithinRange
- getElementType
- getElementVelocity
- getLowLODElement
- getRootElement
- isElement
- isElementAttached
- isElementCallPropagationEnabled
- isElementDoubleSided
- isElementFrozen
- isElementInWater
- isElementLowLOD
- isElementWithinColShape
- isElementWithinMarker
- setElementAlpha
- setElementAngularVelocity
- getElementAngularVelocity
- setElementAttachedOffsets
- setElementCallPropagationEnabled
- setElementCollisionsEnabled
- setElementData
- setElementDimension
- setElementDoubleSided
- setElementFrozen
- setElementHealth
- setElementID
- setElementInterior
- setElementModel
- setElementParent
- setElementPosition
- setElementRotation
- setElementVelocity
- setLowLODElement
- getPedContactElement
- getResourceDynamicElementRoot
- getResourceRootElement