Jump to content

Native functions and ResourceRoot


Mature

Recommended Posts

First of all, to clarify, onVehicleEnter, onClientClick etc. are native events, not native functions.

resourceRoot contains all the elements created by thisResource. If you want to handle all objects created by this resource, you'll want to bind the events on resourceRoot. If you want to handle foreign elements (from other resources), you'll need to use root. If you're only interested in handling a specific element or elements, use (multiple) bind(s) to single element(s).

onVehicleEnter on resourceRoot will only trigger for any player or ped who enters a vehicle created by this resource.
onVehicleEnter on root will trigger for players or peds entering any vehicle, regardless of which resource created it.

onClientClick's source is always root, so I don't think it will trigger for resourceRoot at all.

You have to look at the wiki pages for each event, check what the source of the event is, and determine what element to attach the handler to. Root attaches onto everything (unless you set propagate to false), resourceRoot attaches to everything created by your resource. It goes down the element tree.

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