Mature Posted February 1, 2020 Share Posted February 1, 2020 Hello, should native functions like 'onVehicleEnter' or 'onClientClick' be used ResourceRoot, or are they just trigger created on the resource? Link to comment
Addlibs Posted February 2, 2020 Share Posted February 2, 2020 (edited) 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 February 2, 2020 by MrTasty Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now