Jump to content

getRootElement() vs getResourceRootElement()


srslyyyy

Recommended Posts

  • Scripting Moderators

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.

 

Link to comment

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
Link to comment

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
Link to comment

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...