Kayl Posted December 8, 2009 Share Posted December 8, 2009 (edited) Hello, I have, for a mini-game, a requirement to hide some gui elements, such as buttons and windows. Since those elements belong to the freeroam resource and have known names, it easy to find them and force their visibility to "false" simply by looking at the results of getElementsByType("gui-window") and getElementsByType("gui-button"). However I have noticed that this getElementsByType function, for some players only, doesn't return anything for the aforementioned types. When looking at GetElementsByType we can see that the gui types are not referenced even though they appear in the Element tree. It seems that the players for which it doesn't work are running the 1.0 version whereas those for which it works have 1.0.2. Is there a documented change that explains why GetElementsByType now works with the GUI types, and is there a way to make it work for 1.0 or should I just prevent the access to this minigame for 1.0 users? Thanks. Edited December 9, 2009 by Guest Link to comment
darkdreamingdan Posted December 8, 2009 Share Posted December 8, 2009 1.0 contained a bug related to getElementsByType and it being used onClientResourceStart. You can probably dodge it for 1.0 users by using a timer or something of that sort - i dont fully recall the symptoms of the issue. Give it a try. Link to comment
Kayl Posted December 8, 2009 Author Share Posted December 8, 2009 Thanks for the quick reply. However it is called during the mini-game process hence long after the resource was started. Link to comment
eAi Posted December 8, 2009 Share Posted December 8, 2009 You can manually iterate over the element tree, if you're specific enough this shouldn't be too slow. Use getElementChildren on the root node for the resource, combined with getElementType. See https://wiki.multitheftauto.com/wiki/Ser ... _functions Link to comment
Kayl Posted December 8, 2009 Author Share Posted December 8, 2009 Ok that sounds like a potential fix. I'll call it only when getElementsByType fails (hence only for 1.0 normally). I'll post the results here. Link to comment
eAi Posted December 8, 2009 Share Posted December 8, 2009 Remember you'll need to call getElementChildren recursively... Link to comment
Kayl Posted December 8, 2009 Author Share Posted December 8, 2009 Yep that's what I'm currently doing, thx for the reminder though. I'll tell you if it fixed it as soon as I can test it with the "bad" players Link to comment
Kayl Posted December 9, 2009 Author Share Posted December 9, 2009 I couldn't wait to test with players, I downloaded 1.0 client and was able to confirm the bug. With the method of traversing the element tree manually however it works fine and gui elements can be found and hidden correctly. Since it's pretty quick and well targeted, I decided to go for this method even for 1.0.2 players. Thanks for the tip. 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