DgsSetParent: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
Line 10: Line 10:


===Required Arguments===  
===Required Arguments===  
*'''theDGSElement:''' The dgs element that you wish to set the parent of.
*'''theElement:''' The dgs element that you wish to set the parent of.
*'''parent:''' The dgs element you wish to be the parent of ''theDGSElement''.
*'''parent:''' The dgs element you wish to be the parent of ''theElement''.


===Returns===
===Returns===
Line 28: Line 28:
</syntaxhighlight>
</syntaxhighlight>


This is the equivalent of:
<syntaxhighlight lang="xml">
<spawngroup id="Group of spawn points">
  <spawnpoint id="spawnpoint_0" posX="2507.8715820313" posY="2772.6071777344" posZ="10.8203125" rot="270" skin="285"/>
  <spawnpoint id="spawnpoint_1" posX="2508.060546875" posY="2780.3647460938" posZ="10.8203125" rot="270" skin="285"/>
  <spawnpoint id="spawnpoint_2" posX="2508.0053710938" posY="2776.2897949219" posZ="10.8203125" rot="270" skin="285"/>
  <spawnpoint id="spawnpoint_3" posX="2510.6899414063" posY="2778.3745117188" posZ="10.8203125" rot="270" skin="285"/>
</spawngroup></syntaxhighlight>
</section>
</section>


==See Also==
==See Also==
{{element functions}}
{{element functions}}

Revision as of 09:18, 27 June 2017

This function is used for setting a DGS element as the parent of another DGS element.

[[{{{image}}}|link=|]] Note: This function does not change when an element will be destroyed - DGS elements are always destroyed when the resource that created them is stopped.
[[{{{image}}}|link=|]] Note: dgsSetParent only works to DGS elements.

Syntax

bool dgsSetParent( element theElement, element parent )  

Required Arguments

  • theElement: The dgs element that you wish to set the parent of.
  • parent: The dgs element you wish to be the parent of theElement.

Returns

Returns true if both elements are valid, false otherwise.

Example

Click to collapse [-]
Server

This example sets the parent of each spawnpoint to a dummy element:

dummyElem = createElement ( "spawngroup", "Group of spawn points" ) -- create a dummy element
local spawnpoints = getElementsByType ( "spawnpoint" ) -- get a table of spawn point elements
for k,v in ipairs (spawnpoints) do -- loop through the table of spawn points
   setElementParent ( v, dummyElem ) -- set the dummy element as the parent of the spawn point
end
-- all of the spawn points are now children of 'dummyElem'

See Also