Skip to content

Commit 22b4b8c

Browse files
committed
Element functions
1 parent ef99af2 commit 22b4b8c

File tree

314 files changed

+5100
-2402
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

314 files changed

+5100
-2402
lines changed

assets/images/rotation_ypr.webp

6.22 KB
Loading

assets/images/setElementAlpha.png

470 KB
Loading
17.1 KB
Loading
13.3 KB
Loading
Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
1-
# Scraped from: https://wiki.multitheftauto.com/wiki/AddElementDataSubscriber
2-
shared:
1+
server:
32
name: addElementDataSubscriber
4-
description: 'This function subscribes a [player](/wiki/Player "Player") to specific
5-
[element data](/wiki/Element_data "Element data").
6-
7-
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.
94
parameters:
105
- name: theElement
116
type: element
@@ -18,23 +13,22 @@ shared:
1813
description: The player you wish to subscribe.
1914
examples:
2015
- path: examples/addElementDataSubscriber-1.lua
21-
description: ''
22-
side: server
16+
- path: examples/addElementDataSubscriber_OOP-1.lua
17+
oop: true
2318
returns:
2419
values:
2520
- type: bool
26-
name: value
27-
description: Returns true if the player was subscribed, false otherwise.
21+
name: result
22+
description: Returns **true** if the player was subscribed, **false** otherwise.
2823
oop:
2924
element: element
3025
method: addDataSubscriber
3126
static: false
3227
pair: removeElementDataSubscriber
3328
notes:
3429
- type: info
35-
content: Before using this function you need to setup an initial value of element
36-
data in "subscribe" mode, otherwise the subscriber will not be added.
37-
- type: info
38-
content: Calling removeElementData or setElementData with other sync mode will
39-
automatically remove all subscribers of specified element data.
40-
requires_review: true
30+
content: |
31+
- Before using this function you need to setup an initial value of element
32+
data in `"subscribe"` mode, otherwise the subscriber will not be added.
33+
- Calling [[removeElementData]] or [[setElementData]] with other sync mode will
34+
automatically remove all subscribers of specified element data.
Lines changed: 39 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
# Scraped from: https://wiki.multitheftauto.com/wiki/AttachElements
2-
shared:
1+
shared: &shared
32
name: attachElements
4-
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.
64
parameters:
75
- name: theElement
86
type: element
@@ -12,54 +10,68 @@ shared:
1210
description: The element to attach the first to.
1311
- name: xPosOffset
1412
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.
1715
default: '0'
1816
- name: "yPosOffset"
1917
type: float
20-
description: The y offset (default 0).
18+
description: The Y offset.
2119
default: '0'
2220
- name: zPosOffset
2321
type: float
24-
description: The z offset (default 0).
22+
description: The Z offset.
2523
default: '0'
2624
- name: xRotOffset
2725
type: float
28-
description: The x rotation offset (default 0).
26+
description: The X rotation offset.
2927
default: '0'
3028
- name: "yRotOffset"
3129
type: float
32-
description: The y rotation offset (default 0).
30+
description: The Y rotation offset.
3331
default: '0'
3432
- name: zRotOffset
3533
type: float
36-
description: The z rotation offset (default 0).
34+
description: The Z rotation offset.
3735
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
4736
returns:
4837
values:
4938
- 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.
5241
oop:
5342
element: element
5443
method: attach
44+
variable: attachedTo
45+
note: The variable can only be used if the offsets can be 0 (use [setElementAttachedOffsets](/reference/setElementAttachedOffsets)).
5546
static: false
5647
pair: detachElements
5748
notes:
5849
- 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.
6052
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
6356
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.
76+
- path: examples/attachElements_OOP-2.lua
77+
oop: true
Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,23 @@
1-
# Scraped from: https://wiki.multitheftauto.com/wiki/ClearElementVisibleTo
2-
shared:
1+
server:
32
name: clearElementVisibleTo
4-
description: This function clears any settings added by [setElementVisibleTo](/wiki/SetElementVisibleTo
5-
"SetElementVisibleTo") and restores an [element](/wiki/Element "Element") to its
6-
default [visibility](/wiki/Visibility "Visibility").
3+
pair: setElementVisibleTo
4+
description: This function clears any settings added by [[setElementVisibleTo]] and restores an element to its default [[Visibility]].
75
parameters:
86
- name: theElement
97
type: element
10-
description: The element in which you wish to restore to its default visibility
8+
description: The element in which you wish to restore to its default visibility.
119
examples:
1210
- path: examples/clearElementVisibleTo-1.lua
13-
description: This example clears any visibility settings after a player dies,
14-
so everyone can see his blip for a short period
15-
side: server
11+
description: This example clears any visibility settings after a player dies, so everyone can see his blip for a short period.
12+
- path: examples/clearElementVisibleTo_OOP-1.lua
13+
description: This example clears any visibility settings after a player dies, so everyone can see his blip for a short period.
14+
oop: true
1615
returns:
1716
values:
1817
- type: bool
19-
name: value
20-
description: Returns true if the operation was successful, false otherwise.
18+
name: result
19+
description: Returns **true** if the operation was successful, **false** otherwise.
2120
oop:
2221
element: element
2322
method: clearVisibility
24-
static: false
25-
requires_review: true
23+
static: false

functions/Element/cloneElement.yaml

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1-
# Scraped from: https://wiki.multitheftauto.com/wiki/CloneElement
2-
shared:
1+
server:
32
name: cloneElement
43
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.
85
parameters:
96
- name: theElement
107
type: element
@@ -28,17 +25,25 @@ shared:
2825
default: 'false'
2926
examples:
3027
- 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
3229
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
3434
returns:
3535
values:
3636
- 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**
3939
if invalid arguments were passed.
4040
oop:
41-
element: element
41+
element: element|false
4242
method: clone
4343
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.
Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
# Scraped from: https://wiki.multitheftauto.com/wiki/CreateElement
21
shared:
32
name: createElement
4-
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
65
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**.
87
parameters:
98
- name: elementType
109
type: string
@@ -15,20 +14,32 @@ shared:
1514
default: nil
1615
examples:
1716
- 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
2537
returns:
2638
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**
3042
if the arguments are wrong.
3143
oop:
3244
element: element
33-
constructorclass: Element
34-
requires_review: true
45+
constructorclass: Element
Lines changed: 31 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
# Scraped from: https://wiki.multitheftauto.com/wiki/DestroyElement
2-
shared:
1+
shared: &shared
32
name: destroyElement
4-
description: This function destroys an [element](/wiki/Element "Element") and all
3+
pair: createElement
4+
description: This function destroys an [[element]] and all
55
elements within it in the hierarchy (its children, the children of those children
6-
etc). [Player](/wiki/Player "Player") elements cannot be destroyed using this
6+
etc). [[player]] elements cannot be destroyed using this
77
function. A player can only be removed from the hierarchy when they quit or are
8-
kicked. The root element also cannot be destroyed, however, passing the root as
8+
kicked. The [[root]] element also cannot be destroyed, however, passing the root as
99
an argument will wipe all elements from the server, except for the players and
1010
clients, which will become direct descendants of the root node, and other elements
1111
that cannot be destroyed, such as resource root elements.
@@ -15,45 +15,44 @@ shared:
1515
description: The element you wish to destroy.
1616
examples:
1717
- path: examples/destroyElement-1.lua
18-
description: Example 1:This example would destroy every element in the map, with
19-
the exception of players and the root element itself.
20-
side: server
18+
description: This example would destroy every element in the map, with the exception of players and the root element itself.
2119
- path: examples/destroyElement-2.lua
22-
description: 'Example 2:This example destroys all vehicles of the specified model:'
23-
side: server
24-
- path: examples/destroyElement-3.lua
25-
description: Example 3:This example allows creation of claymores, which trigger
26-
and explode. When they explode, the colshape and object for the claymore are
27-
destroyed.
28-
side: server
20+
description: 'This example destroys all vehicles of the specified model.'
21+
- path: examples/destroyElement_OOP-1.lua
22+
description: 'This example destroys all vehicles of the specified model.'
23+
oop: true
2924
- path: examples/destroyElement-4.lua
30-
description: 'Example 4:This example destroys all vehicles, regardless of ID,
31-
name, etc:'
32-
side: server
25+
description: 'This example destroys all vehicles, regardless of ID, name, etc.'
3326
returns:
3427
values:
3528
- type: bool
36-
name: value
37-
description: Returns true if the element was destroyed successfully, false if
29+
name: result
30+
description: Returns **true** if the element was destroyed successfully, **false** if
3831
either the element passed to it was invalid or it could not be destroyed for
3932
some other reason (for example, clientside destroyElement can't destroy serverside
4033
elements).
4134
oop:
4235
element: element
4336
method: destroy
44-
static: false
4537
notes:
38+
- type: tip
39+
content: There is bug when you try to destroy webbrowser that returned from [[guiGetBrowser]]
40+
so instead of that destroy the gui-element one that returned from [[guiCreateBrowser]]
41+
otherwise the game will be crushed.
4642
- type: info
47-
content: There is bug when you try to destroy webbrowser that returned from guiGetBrowser
48-
so instead of that destroy the gui-element one that returned from guiCreateBrowser
49-
otherwise the game will be crushed (By Master_MTA).
50-
- type: info
51-
content: As element ids are eventually recycled, always make sure you nil variables
52-
containing the element after calling this function
53-
- type: info
54-
content: If a streamed-in element is destroyed then it is NOT streamed out, i.e.
55-
the onClientElementStreamOut client-side event is NOT triggered. Thus it is
43+
content: |
44+
- As element ids are eventually recycled, always make sure you nil variables
45+
containing the element after calling this function
46+
- If a streamed-in element is destroyed then it is **NOT** streamed out, i.e.
47+
the [[onClientElementStreamOut]] client-side event is **NOT** triggered. Thus it is
5648
wrong to assume a clean stream-in and stream-out sequence on the client-side.
57-
Additionally to onClientElementStreamOut use a onClientElementDestroy event
49+
Additionally to [[onClientElementStreamOut]] use a [[onClientElementDestroy]] event
5850
handler to detect the destruction of streamed-in elements.
59-
requires_review: true
51+
52+
server:
53+
<<: *shared
54+
examples:
55+
- path: examples/destroyElement-3.lua
56+
description: This example allows creation of claymores, which trigger
57+
and explode. When they explode, the colshape and object for the claymore are
58+
destroyed.

0 commit comments

Comments
 (0)