Jump to content

getElementsByType VS GUI Elements [solved]


Kayl

Recommended Posts

Posted (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 by Guest
Posted

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.

Posted

Thanks for the quick reply. However it is called during the mini-game process hence long after the resource was started.

Posted

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.

Posted

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 :D

Posted

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.

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...