Jump to content

getRootElement() vs getResourceRootElement()


sacr1ficez

Recommended Posts

Posted

Hi. I have some questions about things above.

As far i understand:

getRootElement()

it's same as

root

and 

getResourceRootElement()

it's same as

resourceRoot

 

But i don't really understand where i should use getRootElement() / getResourceRootElement(). Can someone explain me about this, would be nice with a 2 examples.

 

Posted (edited)

See this: https://wiki.multitheftauto.com/wiki/Element_tree

The root element contains every single element present on the server (or each client if used clientside).
Resource root element contains every element under that resource, so if the resource creates an object using createObject, it will be contained within the resource root but also within the root element (as that contains all the resources).

It's like XML.

Edited by MIKI785
  • Thanks 1
Posted

resourceRoot is used only on 'onClientResourceStart' and on 'onResourceStart'

If you use root on the events mentioned above, when any resource starts, it will get triggered for all resources, so with resourceRoot it will get only triggered for the resource that you you want to know that it started

root is used on any other events, like 'onPlayerJoin' or 'onClientMarkerHit'

  • Thanks 1
  • Discord Moderators
Posted

What MIKI785 said is correct.

In theory you could use resourceRoot to, for example, blow up a vehicle, but only a vehicle that was created by that resource.

  • Thanks 1

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...