Hale Posted May 3, 2017 Share Posted May 3, 2017 I've been using setElementID for many different element types, such as vehicles, objects, players, items, cameras and so on. Now when I use getElementByID on an element with low ID, how to get the exact element I want? I've tried using the second optional argument 'index' but that is sort of useless when I have 10+ different elements with the same ID. Any ideas for how to get the exact element I want, that will have the fastest performance? Link to comment
Fist Posted May 3, 2017 Share Posted May 3, 2017 Why not just to name every element with different names then? Link to comment
Hale Posted May 4, 2017 Author Share Posted May 4, 2017 Too much of a hassle I guess? Does anyone else have any other suggestion, pretty please? Link to comment
pa3ck Posted May 5, 2017 Share Posted May 5, 2017 (edited) If they all have the same index, there's no way you will find the exact one you are looking for. That's the whole purpose of giving the objects a unique identifier. Edited May 5, 2017 by pa3ck Link to comment
Hale Posted May 6, 2017 Author Share Posted May 6, 2017 Never mind, I found the best (I think so at least) way to get the exact element type that has that exact ID. By combining these two functions: getElementsByType() getElementID() Link to comment
Moderators IIYAMA Posted May 16, 2017 Moderators Share Posted May 16, 2017 Usually id's should be unique... ehm, they actually should always be unique, no excuses. The fastest way would be element nesting: https://wiki.multitheftauto.com/wiki/GetElementChildren 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