Jump to content

Elements help


Trixas

Recommended Posts

Element tree is the following:

Root - master of everything

Player - a direct child of the root element (this is a player)

Resource root - a direct child of the root element (this is a resource)

Resource root's dynamic element root - a direct child of the resource root (this is all elements created by the resources script [.lua])

Resource root's map root element - a direct child of the resource root (this is all elements created by the resources maps [.map])

Whenever you want to do something for everything (all of its children), which are players and resources, you call for getRootElement( ). This contains everything.

Whenever you want to do something for just an exact resource (all of its children), you call for getResourceRootElement( ). This is the root of a resource.

Whenever you want to do something for just dynamic elements of a resource (e.g. objects created by createObject), you call for getResourceDynamicElementRoot( ). This is the root of dynamic elements within a resource's scripts.

Whenever you want to do something for just map elements of a resource (elements found within a resource's .map file), you call for getResourceMapRootElement( ). This is the root of elements within a resource's map.

This is why you see map elements and dynamic elements of a resource be removed when you stop the resource. Because these elements are children of their parent root, which then again is a parent of the resource root. Which then is a parent of the root element, so when you shut down the server, you "unload" the master of everything, which causes the server to shut down eventually because there is nothing anymore.

This is why it is also discouraged to use getRootElement( ) in applications, but rather be more specific of which root you actually need. If you just need to do something to dynamic elements created by a resource, you do not need every resource, but just that one resource, and not even that, but the dynamic element root of that resource, which is why you use getResourceDynamicElementRoot( ) instead. This makes everything efficient, faster, better and obviously cleaner.

----

The "source", "client" stuff you mentioned are not directly related to element root at all. Those are related to other things, but those are good to know as well.

Did this help you at all?

P.S. If there are some wiseasses trying to revise something in my post, do not bother. This is supposed to be a basic representation of the system. You can go hardcore on the Tutorials forum, but not on this thread, sorry.

Edited by Guest
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...