Sorry, we don't support your browser.  Install a modern browser

XML UI does not synchronize input values across clients.#2262

Workaround if you encounter this issue: All inputFields in your XML UI must have onValueChanged handlers. These onValueChanged handlers must set the element’s Text attribute in order for the value to update for other users. E.g.:

<InputField onValueChanged="onValueChanged" />
function onValueChanged(player, value, id)
    self.UI.setAttribute(id, "Text", value)
end

There is, as far as I have seen, nothing in the XML UI documentation that makes it clear that you need to do anything to have the UI’s state synchronize across all clients. However, it seems like unless you have a handler attached to InputFields that sets their Text attribute, what one user types into an XML UI will not be reflected for other users.

Tested using the attached savefile. An object has a UI with four InputFields. They have, respectively:

  • No onValueChanged handler.
  • An onValueChanged handler that logs.
  • An onValueChanged handler that logs, and updates the InputField’s value with self.UI.setValue.
  • An onValueChanged handler that logs, and updates’s the InputField’s “Text” attribute with self.UI.setAttribute.

On the server, some values are input into all of the fields (20240325183729_1.jpg). Another player joins and observes that the first two fields are empty, but that the bottom two are populated (20240325183811_1_Before.jpg).

With the user connected, more text is typed in all of the fields (20240325183824_1.jpg). The other user will only see the fourth field (with the handler that updates that element’s Text attribute) update (20240325183900_1_After.jpg).

a month ago