You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This function is used together with [setElementData](/wiki/SetElementData "SetElementData")
8
-
in *"subscribe"* mode.'
3
+
description: This function subscribes a [[player]] to specific [element data](/reference/Element_data). This function is used together with [[setElementData]] in `"subscribe"` mode.
description: This function attaches one element to another, so that the first one
5
-
follows the second whenever it moves.
3
+
description: This function attaches one [[element]] to another, so that the first one follows the second whenever it moves.
6
4
parameters:
7
5
- name: theElement
8
6
type: element
@@ -12,54 +10,68 @@ shared:
12
10
description: The element to attach the first to.
13
11
- name: xPosOffset
14
12
type: float
15
-
description: The x offset, if you want the elements to be a certain distance from
16
-
one another (default 0).
13
+
description: The X offset, if you want the elements to be a certain distance from
14
+
one another.
17
15
default: '0'
18
16
- name: "yPosOffset"
19
17
type: float
20
-
description: The y offset (default 0).
18
+
description: The Y offset.
21
19
default: '0'
22
20
- name: zPosOffset
23
21
type: float
24
-
description: The z offset (default 0).
22
+
description: The Z offset.
25
23
default: '0'
26
24
- name: xRotOffset
27
25
type: float
28
-
description: The x rotation offset (default 0).
26
+
description: The X rotation offset.
29
27
default: '0'
30
28
- name: "yRotOffset"
31
29
type: float
32
-
description: The y rotation offset (default 0).
30
+
description: The Y rotation offset.
33
31
default: '0'
34
32
- name: zRotOffset
35
33
type: float
36
-
description: The z rotation offset (default 0).
34
+
description: The Z rotation offset.
37
35
default: '0'
38
-
examples:
39
-
- path: examples/attachElements-1.lua
40
-
description: 'Example 1:This example attaches a marker to the player who steals
41
-
the Mr. Whoopee:'
42
-
side: server
43
-
- path: examples/attachElements-2.lua
44
-
description: Example 3:This function adds a tank on top of a player (for extra
45
-
defense), clientside. This means it will be invisible to other players.
46
-
side: client
47
36
returns:
48
37
values:
49
38
- type: bool
50
-
name: value
51
-
description: Returns true if the attaching process was successful, false otherwise.
39
+
name: result
40
+
description: Returns **true** if the attaching process was successful, **false** otherwise.
52
41
oop:
53
42
element: element
54
43
method: attach
44
+
variable: attachedTo
45
+
note: The variable can only be used if the offsets can be 0 (use [setElementAttachedOffsets](/reference/setElementAttachedOffsets)).
55
46
static: false
56
47
pair: detachElements
57
48
notes:
58
49
- type: info
59
-
content: The offset coodinates reflect the object space, not the world space.
50
+
content: |
51
+
- The offset coodinates reflect the object space, not the world space.
60
52
This means that you cannot calculate the exact offsets between two objects by
61
-
pre-positioning them in the map editor as a reference. Please see attachElementsOffsets
62
-
for more details. Due to a limitation in GTA, unexpected attach rotations may
53
+
pre-positioning them in the map editor as a reference. Please see [[attachElementsOffsets]]
54
+
for more details.
55
+
- Due to a limitation in GTA, unexpected attach rotations may
63
56
occur if all rotation offsets are non-zero. (i.e. Try to ensure at least one
64
-
of 'xRotOffset', 'yRotOffset' or 'zRotOffset' is zero).
65
-
requires_review: true
57
+
of `xRotOffset`, `yRotOffset` or `zRotOffset` is zero).
58
+
- If an attempt is made to attach two elements that are already attached the opposite way (eg `theElement` becomes `theAttachToElement` and vice versa), the 1st attachment order is automatically detached in favor of the 2nd attachment order. For example, if carA was attached to carB, now carB is attached to carA. Also, an element cannot be attached to two separate elements at one time. For example, two cars can be attached to one single car, but one single car cannot be attached to two separate cars. If you attempt to do this, the existing attachment will automatically be dropped in favor of the new attachment. For example, if carA is asked to attached to carB then carC, it is only attached to carC.
59
+
- This is not compatible with all elements. The following elements are compatible: [[ped]], [[player]], [[blip]], [[vehicle]], [[object]], [[marker]], [[pickup]], [[sound]], [[colshape]], [[weapon]], [[camera]], [[light]].
60
+
server:
61
+
<<: *shared
62
+
examples:
63
+
- path: examples/attachElements-1.lua
64
+
description: 'This example attaches a marker to the player who steals the Mr. Whoopee.'
65
+
- path: examples/attachElements-2.lua
66
+
description: This function adds a tank on top of a player (for extra defense).
67
+
- path: examples/attachElements_OOP-1.lua
68
+
description: This function adds a tank on top of a player (for extra defense).
69
+
oop: true
70
+
71
+
client:
72
+
<<: *shared
73
+
examples:
74
+
- path: 'examples/attachElements-3.lua'
75
+
description: This function adds a tank on top of a player (for extra defense), clientside. This means it will be invisible to other players.
description: This function clones (creates an exact copy of) an already existing
5
-
element. The root node, and player elements, cannot be cloned. If a player element
6
-
is a child of an element that is cloned, it will be skipped, along with the elements
7
-
that exist as a child to the player element.
4
+
element.
8
5
parameters:
9
6
- name: theElement
10
7
type: element
@@ -28,17 +25,25 @@ shared:
28
25
default: 'false'
29
26
examples:
30
27
- path: examples/cloneElement-1.lua
31
-
description: This example clones the vehicle a player is in. This allows carrying
28
+
description: This example clones the vehicle a player is in. This allows carrying
32
29
over of the current state of the vehicle, including mods, for example.
33
-
side: server
30
+
- path: examples/cloneElement_OOP-1.lua
31
+
description: This example clones the vehicle a player is in. This allows carrying
32
+
over of the current state of the vehicle, including mods, for example.
33
+
oop: true
34
34
returns:
35
35
values:
36
36
- type: element
37
-
name: value
38
-
description: Returns the handle of the new cloned element of the parent, false
37
+
name: cloned element
38
+
description: Returns the handle of the new cloned element of the parent, **false**
39
39
if invalid arguments were passed.
40
40
oop:
41
-
element: element
41
+
element: element|false
42
42
method: clone
43
43
static: false
44
-
requires_review: true
44
+
notes:
45
+
- type: info
46
+
content: |
47
+
- if `cloneChildren` is **true**, the position floats will be offsets from the cloned element's position.
48
+
- 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.
49
+
- The cloned element will be placed on the [element tree](/reference/Element_tree) as a child of the same parent as the cloned element.
description: This function is used to create a new dummy element in the [element
5
-
tree](/wiki/Element_tree "Element tree") which do not necessarily represent an
3
+
pair: destroyElement
4
+
description: This function is used to create a new dummy [[element]] in the [element tree](/reference/Element_tree) which do not necessarily represent an
6
5
entity within the San Andreas world. A common use for this function is for creating
7
-
custom elements, such as a Flag or a Base.
6
+
custom elements, such as a **Flag** or a **Base**.
8
7
parameters:
9
8
- name: elementType
10
9
type: string
@@ -15,20 +14,32 @@ shared:
15
14
default: nil
16
15
examples:
17
16
- path: examples/createElement-1.lua
18
-
description: This example creates a "flag" element, named "blue", which will be
19
-
at the resource's dynamic map.
20
-
side: server
21
-
- path: examples/createElement-2.lua
22
-
description: 'Except for it being placed in a different map root, that line will
23
-
have the same effect as having this in a .map file:'
24
-
side: server
17
+
description: |
18
+
This example creates a "flag" element, named "blue", which will be at the resource's dynamic map.
19
+
20
+
Except for it being placed in a different map root, that line will have the same effect as having this in a .map file:
21
+
```xml
22
+
<flag id="blue" />
23
+
````
24
+
25
+
Lua
26
+
- path: examples/createElement_OOP-1.lua
27
+
description: |
28
+
This example creates a "flag" element, named "blue", which will be at the resource's dynamic map.
29
+
30
+
Except for it being placed in a different map root, that line will have the same effect as having this in a .map file:
31
+
```xml
32
+
<flag id="blue" />
33
+
````
34
+
35
+
Lua
36
+
oop: true
25
37
returns:
26
38
values:
27
-
- type: element
28
-
name: value
29
-
description: Returns the element if it was successfully created. Returns false
39
+
- type: element|false
40
+
name: created element
41
+
description: Returns the [[element]] if it was successfully created. Returns **false**
0 commit comments