cloneElement
Client-side
Server-side
Shared
This function clones (creates an exact copy of) an already existing element.
Note
- if
cloneChildrenis true, the position floats will be offsets from the cloned element's position. - The root node, and player elements, cannot be cloned. If a player element is a child of an element that is cloned, it will be skipped, along with the elements that exist as a child to the player element. Players are not the only elements that cannot be cloned. This list also includes remoteclients, and console elements.
- The cloned element will be placed on the element tree as a child of the same parent as the cloned element.
OOP Syntax Help! I don't understand this!
- Method:element|false:clone(...)
Syntax
element cloneElement ( element theElement, [ float xPos = 0, float yPos = 0, float zPos = 0, bool cloneChildren = false ] )Required Arguments
- theElement: The element that you wish to clone.
Optional Arguments
NOTE: When using optional arguments, you might need to supply all arguments before the one you wish to use.
- xPos (default: 0): A floating point number representing the X coordinate on the map.
- yPos (default: 0): A floating point number representing the Y coordinate on the map.
- zPos (default: 0): A floating point number representing the Z coordinate on the map.
- cloneChildren (default: false): A boolean value representing whether or not the element's children will be cloned.
Returns
- element: cloned element
Returns the handle of the new cloned element of the parent, false if invalid arguments were passed.
Code Examples
server
This example clones the vehicle a player is in. This allows carrying over of the current state of the vehicle, including mods, for example.
function cloneVehicle(thePlayer, commandName) local occupiedVehicle = getPedOccupiedVehicle(thePlayer) -- get the player's vehicle if occupiedVehicle then -- If the player is actually in a vehicle local x, y, z = getElementPosition(occupiedVehicle) -- get the vehicle's position local clone = cloneElement(occupiedVehicle, x + 5, y, z) -- create a clone of the vehicle near it else outputChatBox("You can't clone a vehicle if you're not in a vehicle", thePlayer, 255, 0, 0) endendaddCommandHandler("clone", cloneVehicle)See Also
Element Functions
- addElementDataSubscriber
- attachElements
- clearElementVisibleTo
- cloneElement
- createElement
- destroyElement
- detachElements
- getAllElementDataUpdated
- getAttachedElements
- getElementAlpha
- getElementAngularVelocity
- getElementAttachedOffsets
- getElementAttachedTo
- getElementBonePosition
- getElementBoneQuaternionNew
- getElementBoneRotation
- getElementBoundingBox
- getElementByID
- getElementByIndex
- getElementChild
- getElementChildren
- getElementChildrenCount
- getElementCollisionsEnabled
- getElementColShape
- getElementData
- getElementDimension
- getElementDistanceFromCentreOfMassToBaseOfModel
- getElementHealth
- getElementID
- getElementInterior
- getElementLighting
- getElementMatrix
- getElementModel
- getElementParent
- getElementPosition
- getElementRadius
- getElementRotation
- getElementsByType
- getElementsWithinColShape
- getElementsWithinRange
- getElementSyncer
- getElementType
- getElementVelocity
- getElementZoneName
- getLowLODElement
- getRootElement
- hasElementData
- hasElementDataSubscriber
- isElement
- isElementAttached
- isElementCallPropagationEnabled
- isElementCollidableWith
- isElementDoubleSided
- isElementFrozen
- isElementInWater
- isElementLocal
- isElementLowLOD
- isElementOnFireNew
- isElementOnScreen
- isElementStreamable
- isElementStreamedIn
- isElementSyncer
- isElementVisibleTo
- isElementWaitingForGroundToLoad
- isElementWithinColShape
- isElementWithinMarker
- removeElementData
- removeElementDataSubscriber
- setElementAlpha
- setElementAngularVelocity
- setElementAttachedOffsets
- setElementBonePosition
- setElementBoneQuaternionNew
- setElementBoneRotation
- setElementCallPropagationEnabled
- setElementCollidableWith
- setElementCollisionsEnabled
- setElementDataUpdated
- setElementDimension
- setElementDoubleSided
- setElementFrozen
- setElementHealth
- setElementID
- setElementInterior
- setElementLightingNew
- setElementMatrix
- setElementModel
- setElementOnFireNew
- setElementParent
- setElementPosition
- setElementRotation
- setElementStreamable
- setElementSyncer
- setElementVelocity
- setElementVisibleTo
- setLowLODElement
- updateElementRpHAnim
Element Events
- onClientElementColShapeHit
- onClientElementColShapeLeave
- onClientElementDataChange
- onClientElementDestroy
- onClientElementDimensionChange
- onClientElementInteriorChange
- onClientElementModelChange
- onClientElementStreamIn
- onClientElementStreamOut
- onElementClicked
- onElementColShapeHit
- onElementColShapeLeave
- onElementDataChange
- onElementDestroy
- onElementDimensionChange
- onElementInteriorChange
- onElementModelChange
- onElementStartSync
- onElementStopSync